How to save html, javascript and css files in html5 local storage?

Is there a way to store html, javascript and css files in html5 local storage?

I want to make my application faster!

thanks

+6
source share
6 answers

You want to use the application cache for this, not localStorage:

http://www.html5rocks.com/en/tutorials/appcache/beginner/

+9
source

You are not using HTML5 local storage for CSS / JS files; you cache them.

+2
source

I suggest using the client and server side cache instead of storing it in local storage so that you have control over when you need to update (undo the cache), you can also use CDN to deliver static content such as images, js, css

+1
source

Although this is not the best solution, you can cache most of the interface using local storage. Christian Heilmann discussed many ideas in his 2010 24Ways article. Check out this screencast for a complete example on the lines you're thinking of.

Note that to cache images in local storage, you first need Base 64 encode them .

+1
source

Local storage is a key value storage that you prefer to store data objects (json) or individual values, such as strings of ore numbers. Do not save the view layer inside.

0
source

You can use it fully.

When you configure your cache so that the browser checks whether the file has been modified or not, it will request the file, and the CDN will respond with the status code 304, which means that the file in the browser cache can be used. However, this still requires an HTTP request. You can also use etag or expiration so that it does not.

However, it may happen that you download external files from sites where you do not have control over the header. In this case, in order not to have an HTTP request and a 304 response, you could save time by using local storage.

0
source

Source: https://habr.com/ru/post/912506/


All Articles