Reputation: 527
I'm writing a C#/XAML UWP application making extensive use of BitmapImage class and loading lots of images from the internet. From what I've read this class somehow cashes the images it displays, and I've go a few questions about how this cache works:
a) If I load image from a given Url to BitmapImage, supposing that that image under that Url doesn't change, does it mean that when I turn the app off and on again and load a BitmapImage from the same Url, the image is loaded from local cache?
b) If answer to a) is yes, it means that images are strored somewhere on disc/microSD/internal memory/etc. How can I clean this cache? When I download lots of images this cache may take a lot of space, how is this handles by the system?
c) If answer to a) is yes, how does the system determine whether it should download image from Url or load it from cache? The content under given Url can change, so I guess it must keep some kind of hash based on image content. Can it impact performance in significantly noticable way?
Upvotes: 1
Views: 1178
Reputation: 1072
When you turn off the app, the app in going into terminated state and the system will release all allocated resources for this app. If the app doesn't store the image to local store cache before quitting ( BitmapCreateOptions set to IgnoreImageCache) or the cache is cleared before next starting, next time the image is still needed to be loaded from the Url.
The answer to B:
If you want to clear the Windows Store Cache, there is a built-in component to accomplish this:
Press the WinKey+Q to display the Search and type WSRESET.
In the Results, click wsreset to reset the Store Cache.
The Windows Store will open and confirm that the cache has been cleared.
The answer to your question C:
You can determine when and how to cache by setting CreateOptions. You should use BitmapCreateOptions.IgnoreImageCache in cases where you know that the source image file as retrieved by URI has the potential to change over time. The default value is to cache the entire image into memory.
please let me know if anything unclear.
Upvotes: 2