M
M
mx60012015-02-11 09:29:47
JavaScript
mx6001, 2015-02-11 09:29:47

How to bypass browser caching?

The situation is this, in the enterprise, users have Chrome (not tested in other browsers), through which they use my web application. After updating the JS files included in this application on the server, they come back old, i.e. they are already new (changed) on the server, and the browser apparently cached the old code and pulls up as if they had not changed, but pulls up new files. Because of this, errors occur when executing JS.
Moreover, the changed files are pulled up only by updating to F5, if, for example, you get to the application page via a link, or by restarting the browser and going to the applications, they are not updated.
The question is how can this be bypassed?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vladimir Rodkin, 2015-02-11
@mx6001

There are 2 ways:
1. Change the name of the included script file.
For example:
Became like this:
2. Easier, without renaming:
Was:
Became:
<script src="scripts/libs.js?v=2"></script>

G
GM2mars, 2015-02-11
@GM2mars

The most effective and proven way is versioning js files. That is, we released a new version of the web application, we change the name of the app_1.2.js files
How to change the name of the included files automatically, this is another question, it depends on the architecture, and in general you need to look at each situation separately.
Some will say that you can change the version through the app.js?v=1.2 parameters, but this scheme does not work on all browsers.

F
frees2, 2015-02-11
@frees2

Already ate a dog on it. All of the above solutions do not solve the problem comprehensively, of course, if you receive your files, this is fine, but not remote files (some files are cached on the side of the provider and even Google, for example, the shienen tape passes and the other tape does not, so all sorts of local supervisions work, in including in Eastern Europe, censorship).
It's better than .........scripts/libs- 20150211093711 .js Complexly
solved like this
Changing the extension to scripts/libs- 20150211093711 .php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question