Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How are files evicted? #7

Open
nuria opened this issue Nov 5, 2012 · 10 comments
Open

How are files evicted? #7

nuria opened this issue Nov 5, 2012 · 10 comments
Labels

Comments

@nuria
Copy link

nuria commented Nov 5, 2012

Since files are likely to change... how are they evicted from the cache?

@djmc
Copy link
Contributor

djmc commented Nov 5, 2012

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.

@nuria
Copy link
Author

nuria commented Nov 6, 2012

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

@djmc
Copy link
Contributor

djmc commented Nov 6, 2012

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.

@ecstasy2
Copy link

ecstasy2 commented Nov 9, 2012

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

@djmc
Copy link
Contributor

djmc commented Nov 9, 2012

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.

@tarciozemel
Copy link

So, if I want to clean up all files, I have to use this?

new BootUp(["jquery.js?v=1", "site.js?v=2"]);

@djmc
Copy link
Contributor

djmc commented Nov 29, 2012

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.

@tarciozemel
Copy link

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!

@djmc
Copy link
Contributor

djmc commented Nov 29, 2012

If you want to just delete the cache then,

localStorage.removeItem("cache");

@tarciozemel
Copy link

OK, thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants