M
M
Maxim Mzhelsky2010-11-14 10:11:41
JavaScript
Maxim Mzhelsky, 2010-11-14 10:11:41

Update JavaScript script on the client

How to properly organize the connection of JS on the client's site, so that later at any time the JS script can be updated and it will be picked up by all clients, i.e. would the browser caching be reset? JS, for example, the code for connecting some kind of widget.
It is necessary in order not to ask clients to update its connection code on their sites with each script update.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Arsen, 2010-11-14
@mekegi

in the header, loader.js is connected,
which never changes (or rarely enough),
this file loads the necessary js files that change often.
and also in the loader, implement the logic for resolving situations with caching, with versioning, and so on.

[
[email protected]><e, 2010-11-14
@barmaley_exe

When writing the script address in the src attribute of the script tag, add a request like ?v1.0
I.e.


<script type="text/javascript" src="/js/core.js?v1.0"></script>
And after update change to

<script type="text/javascript" src="/js/core.js?v2.0"></script>
(or some other way)

A
Anton Korzunov, 2010-11-14
@kashey

TS should not forget that different tama Chrome and other IE with factory settings may be paranoid not to update the files.
Therefore, a good option is to only include mtime files (or version or whatever) in the file name, or change it completely.
Or completely and completely demolish file caching.
There are no other STABLE options.

K
Kane, 2010-11-14
@Kane

Etag

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question