H
H
hbrmdc2015-07-09 13:35:32
JavaScript
hbrmdc, 2015-07-09 13:35:32

How to use localStorage in SPA (SinglePageApplications)?

There is a SPA on reactJs and Flux. There is a main.js file that contains many thousands of lines.
What is the correct way to save this file on the client side? use cache or localStorage?
Is this the right approach?
Please provide an example of how to do this?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Sergey Melnikov, 2015-07-09
@hbrmdc

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

D
DigitalSmile, 2015-07-09
@DigitalSmile

From the point of view of architecture and Dev-Ops, it is more correct to manage the caching of files on the web server using Etag and cache directly with standard browser tools.

V
Vitaly Kulikov, 2015-07-09
@DarkDefender

Etag is not the best option, the browser will still have to go to the server and compare the values ​​\u200b\u200bof this header. I would suggest exires or cache-control max-age (they are equivalent). If the file is planned to be changed in the future, then after running it through the minimizer / obfuscator, it would set the result as a hash of the content, so that if it changes, the URL would change and the browser would re-request the resource.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question