Search code examples
winapicachingwininet

How to clear MSIE/WinInet cache programmatically?


I'm trying to clear out the WinInet cache using Win32 API - by invalidating the cache entries, or deleting them (doesn't matter). I can't find any way to do this for the whole cache (other than iterating over each entry - example in C#, another in VB) - is this even possible?


Solution

  • I'm fairly certain doing the FindFirst/FindNextUrlCacheEntry() then DeleteUrlCacheEntry() is the only way to make sure it works across all versions of IE.

    Alternatively you can use FindFirst/FindNextUrlCacheGroup() and DeleteUrlCacheGroup() with "CACHEGROUP_FLAG_FLUSHURL_ONDELETE" but you have to make sure you only delete what you want. For example, history, cookies and temporary internet files are all Cache groups.