Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I prevent URLDownloadToFile from retrieving from the cache?

I am using URLDownloadToFile to retrieve a file from a website. Subsequent calls return the original file rather than an updated version. I assume it is retrieving a cached version.

like image 573
AlanKley Avatar asked Dec 01 '22 13:12

AlanKley


2 Answers

Call DeleteUrlCacheEntry with the same URL just prior to calling URLDownloadToFile. You will need to link against Wininet.lib

like image 78
AlanKley Avatar answered Mar 30 '23 00:03

AlanKley


Yes, it is pulling a cached version of the file by default. To avoid the cache file completely, pass an IBindStatusCallback object in the lpfnCB parameter of URLDownloadToFile(). In your implemented IBindStatusCallback::GetBindInfo() method, include the BINDF_GETNEWESTVERSION flag, and optionally also the BINDF_NOWRITECACHE flag, in the value you return via the grfBINDF parameter. If you want the cache file, if present, to be updated instead of skippe, specify the BINDF_RESYNCHRONIZE flag instead.

like image 38
Remy Lebeau Avatar answered Mar 30 '23 01:03

Remy Lebeau