E
E
Eugene2015-02-25 00:07:24
Angular
Eugene, 2015-02-25 00:07:24

How is page caching reset implemented in Single Page Application?

Let's say a user comes in, uploads index.html, scripts, styles, templates.
They hit him in the browser cache.
What is the best way to update the client code so that users do not have to reload the page?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Romanov, 2015-02-25
@Nc_Soft

It's impossible to reset the client cache from the server side. Usually in this case they make an alert system. For example, the version on the server has become larger than the client version. Then the user sees a message on the site that an update has occurred and that he needs to refresh the page if he wants to receive it.
It is not only convenient but also correct. The user must know when and what appeared. So you not only update, but also make sure that users know what's new in the new version, since it will not be difficult to tie the changelog to such a system.
You can also automatically refresh the page if the version has been updated on the server without any notification.
If you have a package.json in your project, you can use $http to read the version in this file. All that is needed at the release is to update the version. To do this, it will be necessary that some script check the data at intervals.
If you do not want an interval to avoid loading, you can embed this into your API. In config, set $httpProvider to always send the current version of the client. And on the server, before issuing data, check this version and if there is an update, then issue a special Json that will reload the page. It is possible to add interceptors that will do this and check with each request automatically.

M
Mikhail Osher, 2015-02-25
@miraage

1) collect, minify, package and serve all code with nginx gzip_static on
OR
2) before loading the route / controller / etc., load the necessary
OR scripts through deferred
3) Ready-made solution (I can’t vouch for performance - Google is issued)
ocLazyLoad

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question