predaware Posted April 11, 2022 Share Posted April 11, 2022 Hi Josh, et al, My project pulls data as a file (using DownloadFile) from my remote server and saves it to the PATH_DOCUMENTS folder. I need to be able re-pull this file down again and see any changes to it reflected in my app. What appears to be happening is that the data is being cached, and the original values retained. Even if I delete the downloaded file using DeleteFile, it gets re-created verbatim. If I re-start the app, then it seems to pull down a fresh copy. I'm only 24 hours into the library, so I'm still getting up to speed, but I thought I read about a caching system somewhere. Is there a way to disable that? Of course, there's still a chance that I'm just doing something wrong, but I don't think so. Thanks for your help, EDIT: I found a work-around (I append the current microseconds as a dummy CGI variable to the URL, which forces the cache to re-download) but would still like to know if there's a proper way to disable the cache or force the download. John Quote Link to comment Share on other sites More sharing options...
Josh Posted April 11, 2022 Share Posted April 11, 2022 Yes, the file downloader stores a local files in the user appdata folder. You can clear the cache by calling ClearWebCache(). 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
predaware Posted April 12, 2022 Author Share Posted April 12, 2022 Ok, I called that function but still seems to download the old version of my data. I verified the URL in a web browser to make sure the contents should be different. Any ideas? Thanks, John Quote Link to comment Share on other sites More sharing options...
Josh Posted April 12, 2022 Share Posted April 12, 2022 The location of the download cache is here: C:\Users\(USERNAME)\AppData\local\Ultra Engine\WebCache Can you delete that folder manually and then see what happens? Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted April 12, 2022 Share Posted April 12, 2022 Also, ClearWebCache will return false if the folder exists but cannot be deleted for some reason. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
predaware Posted April 12, 2022 Author Share Posted April 12, 2022 The Ultra Engine folder only contains a user.dat file, there is no WebCache (checked hidden files also.) Quote Link to comment Share on other sites More sharing options...
predaware Posted April 12, 2022 Author Share Posted April 12, 2022 ClearWebCache is returning true every time, FYI. Quote Link to comment Share on other sites More sharing options...
Josh Posted April 12, 2022 Share Posted April 12, 2022 Actually...calling ReadFile() with a URL will use the cache so that files aren't constantly re-downloaded. DownloadFile does not use the cache and downloads the file every time. It's basically just doing this: bool DownloadFile(const WString& src, const WString& dest) { return URLDownloadToFileW(NULL, src.c_str(), dest.c_str(), 0, NULL) == S_OK; } So there is something else going on with the Windows command or your server? Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
klepto2 Posted April 12, 2022 Share Posted April 12, 2022 Urldownloadfile indeed Caches the downloaded files. To receive the latest version you need to call this: https://docs.microsoft.com/en-us/windows/win32/api/wininet/nf-wininet-deleteurlcacheentry prior to call download file. 2 Quote Windows 10 Pro 64-Bit-Version NVIDIA Geforce 1080 TI Link to comment Share on other sites More sharing options...
predaware Posted April 13, 2022 Author Share Posted April 13, 2022 Ah hah, that is great to know. I will call that for sure...hopefully when I port my app to Mac this will not be a problem. Thanks for taking the time to research this. -John Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.