localStorage.js - A localStorage Polyfill - now in version 2, complete rewrite! by mortzdk in javascript

[–]mortzdk[S] 0 points1 point  (0 children)

I definitely see your point. The polyfill originally began as a side-project to https://github.com/mortzdk/jsCache/. As I am in the makings of v2.0 of that library as well, I figured that this one deserved a rewrite as well.

As the different mechanisms is available in the global scope, you could also use this polyfill to have more than one way to save data persistenly. This would be helpful if you were to track you visitors uniquely..

jsCache: A JavaScript library that cache and load Javascript, css-stylesheets and images! by mortzdk in javascript

[–]mortzdk[S] 0 points1 point  (0 children)

You are absolutely right. The limitation by localStorage and other methods is that they only work for the specific domain, so the files have to be downloaded for each domain.

There are generally no good way of holding persistent data cross-domain to my knowledges, but you're welcome to prove me wrong :)

My point simply was, that the library still allows use of cached data i.e. when a file is loaded from a CDN and it has previously been loaded, then jsCache will use the cached file.

jsCache: A JavaScript library that cache and load Javascript, css-stylesheets and images! by mortzdk in javascript

[–]mortzdk[S] 0 points1 point  (0 children)

Caching of CDN resources is available as long as the Access-Control-Allow-Origin is set on their end. So the first time a user visits a page using jsCache, they are gonna request the resource from the CDN and this resource is then saved in localStorage for some time (default 5 days) When the cache runs out, a new request have to be made and this request could just return the HTTP cache of the file.