开发者

How best to cache images that don't change in every session

开发者 https://www.devze.com 2023-02-05 08:00 出处:网络
HI, For how long data can be saved in Cache folder. I want to cach开发者_StackOverflow中文版e lot of images which I will be using multiple times. What should be the best place to save them?

HI,

For how long data can be saved in Cache folder. I want to cach开发者_StackOverflow中文版e lot of images which I will be using multiple times. What should be the best place to save them?

Also, these images will rarely change like once in a week kind of. So how and when should I trigger the image refreshing without hampering the app experience.


I assume you’re referring to ~/Libraries/Caches/. The system doesn’t automatically remove stuff there, so the answer is “indefinitely”. If you’ll be adding unbounded amounts of data, you need to clean it out yourself.

Keep in mind that by putting data there you’re effectively promising that your app won’t break if it’s deleted at any time, and it won’t be backed up.


Just refresh the images in the cache when you download new ones. Downloading new ones depends on the images, and where they are used. Eg you could cache the Cocoa-Cola Logo indefinitely as it never changes, but say the Google logo (including the doodles) should be checked for pretty much every day, as it can change (like it has changed today)

0

精彩评论

暂无评论...
验证码 换一张
取 消