Working with IE cache
I am writing a program in C # using WPF framework. I need to display images and I would like to cache them so that they don't load all the time.
I can code my own cache, however IE already has a caching system. I can find the code to read entries from the IE cache, however I didn't find anything that dealt with the issue of adding items to the cache. Is there a good way to do this, or should I just implement a separate cache?
a source to share
Depending on how you download the files, they may already be added to the cache. How do you download them now?
You can add items to IE cache. You have several options: URLDownloadToCacheFile () does this in one nice "easy" step. CommitUrlCacheEntry () is the hardcore way to do this. I assume the sample you found uses FindFirst / FindNextUrlCacheEntry () to enumerate the cache, so you should be able to easily add the interop needed by CommitUrlCacheEntry ().
However, as a former member of the IE team, I can't recommend enough that you don't use the Wininet cache for anything. It is not reliable, it can be cleaned from under you, it gets corrupted often, it has some hard limits on how much stuff it can store, it obeys various rules you don't understand, and it will be optimized for IE, not your.
Seriously, don't do this. If you really need a cache, write your own.a source to share
I suggest you implement your own. You cannot rely on IE's cache to stay consistent or not cleared by the user, or whatever. Unless you are embedding an IE browser into a control in your application, I see no reason to use it. Also, using your own cache allows you to create one that might be more suitable for the purpose (for example, if you need to store thumbs or additional metadata or whatever).
a source to share