Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

I want make my webapplication faster!

Thanks

like image 748
robind38 Avatar asked Apr 05 '12 15:04

robind38


4 Answers

You want to use the Application Cache for this, not localStorage:

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

like image 67
hellslam Avatar answered Nov 14 '22 23:11

hellslam


You don't use HTML5 Local storage for CSS/JS files in, you cache them.

like image 35
Dunhamzzz Avatar answered Nov 14 '22 22:11

Dunhamzzz


I suggest to use cache on client and server side instead of storing in local storage this way you have control on when to update(invalidate cache), you can also consider using CDN to deliver static content like images, js, css

like image 34
Sandeep Manne Avatar answered Nov 14 '22 22:11

Sandeep Manne


Even though it's not the best solution, it is possible to cache most of the interface with local storage. Christian Heilmann discussed a lot of ideas in his 2010 24Ways article. Have a look at this screencast for a full example along the lines you're thinking.

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

like image 31
robertc Avatar answered Nov 14 '22 22:11

robertc