How to store a specific JavaScript or a CSS file in local storage of browser programmatically, retrieve it whenever needed and delete it from the local storage if the current session expires.
Let's understand through this example (pseudo-code):
var load_from_server = true;
if (detect local storage)
{
if (cache of css, js found)
{
load the css and js from local storage cache
load_from_server = false;
}
}
if (load_from_server)
{
document.write('<script>...');
}
$( window ).unload(function() {
clear local storage cache
});
I need something like this. I referred plenty of blogs and QA's of stack overflow, but didn't got but didn't what exactly i am looking for. Please suggest How can i do this.?