K
K
korkholeh2010-10-09 13:59:30
JavaScript
korkholeh, 2010-10-09 13:59:30

How to force the browser not to cache JavaScript?

Is there any efficient way to force the browser not to cache a particular Javascript file? It is desirable that this method works in Firefox, Opera and Chrome (IE is not particularly interested).

Answer the question

In order to leave comments, you need to log in

5 answer(s)
O
ojiga, 2010-10-09
@korkholeh

change the file name.
for example, you can script.js?123
instead of a number, for example, I substitute the hash sum of the file

A
Aquahawk, 2010-10-09
@Aquahawk

Or maybe it's easier, on the server side, to include the script directly in html? The script will be reloaded every time the page is refreshed. Usually this is extra traffic, but in your case it will not be superfluous. you need to update the script constantly.

S
Stamm, 2010-10-09
@Stamm

Set the correct headers using the web server.

N
Nikolai Vasilchuk, 2010-10-10
@Anonym

In all browsers I refresh the page with Ctrl+R. Never had a problem with the cache.

B
burgua, 2010-10-09
@burgua

In ff, I disabled caching by setting netwotk.http.use-cache to false.
Tough but it worked.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question