Open nuria opened 12 years ago
We used aggressive caching techniques with our JS, meaning that once they were downloaded they were always there. To make sure people got changes, we'd either append a number to the filename or query string. In Trade Me Touch, we used ASP.nets minification which automatically creates a unique version hash for us.
So that means, it's up to you to "force" a cache change if you make changes to your JS, as the library makes no HTTP requests at all if it already has the file. BootUp will forget any files that aren't mentioned.
So, if you...
new BootUp(["jquery.js?v=1", "site.js?v=1"]);
BootUp will download and remember jquery.js?v=1 and site.js?v=1 (the cache will have jquery.js?v=1 and site.js?v=1).
If you update your site.js...
new BootUp(["jquery.js?v=1", "site.js?v=2"]);
BootUp will download site.js?v=2, but load jquery.js?v=1 from cache (the cache will have jquery.js?v=1 and site.js?v=2).
Hope this helps.
I see, so you are really not evicting files at all. Which means that your storage is growing per every one of your changes. Thanks for the prompt response,
Nuria
so you are really not evicting files at all
Huh, that's not what I said.
If there is a filename in the cache, and it is no longer referenced in your array, then it is removed from the cache. It isn't growing for every one of the changes.
In the examples above, I specified two files, jquery.js and site.js.
In the first one, it downloaded jquery.js?v=1 and site.js?v=1. But when the number was incremented to site.js?v=2, it was downloaded, and site.js?v=1 was forgotten because it is no longer referenced.
In fact you don't have to worry about the cache growing in size. I havent' read the code but seems like it is up to the browser to manage cache size. am i right on this ? @djmc
No, because BootUp is handling all this by itself, the browser just accepts what it is given (unless the size is bigger than the maximum allowed). This means we need to handle this stuff internally, which it does.
So, if I want to clean up all files, I have to use this?
new BootUp(["jquery.js?v=1", "site.js?v=2"]);
What do you mean by "clean up all files"?
If you want to remove and redownload everything, use the refresh flag in the options structure.
The option is "Set to true to delete the local storage cache and redownload everything". If I want (hypothetically) just "to delete the local storage cache"? It's possible?
Regards!
If you want to just delete the cache then,
localStorage.removeItem("cache");
OK, thank you very much!
Since files are likely to change... how are they evicted from the cache?