Tommaso Taruffi
Tommaso Taruffi

Reputation: 9252

HTML Page Reload - Simulation CTRL+F5

I've my web page that use a data javascript. All the javascript are be cached. When I deploy a new version of my application, the user have the problem because the browser continue to use the old javascript and not the new javascript (for caching).

It's possible to simulate, when the page is loading, the FULL reload of all the page, including the javascript and css files (for complete reload of the cache)?

Thanks!!

Tommaso

Upvotes: 4

Views: 6338

Answers (3)

Stefan
Stefan

Reputation: 5662

You should NOT use the meta tags suggested as they would disable the entire cache rather then clearing it for the changed files.

I recommend that you append some version unique value to the path of your files and that only change each time you deploy new changes and not just a random number that change at every page load.

Your question doesn´t tell but if you´re using ASP.NET I suggest you have a look at libraries like SquishIt. It minifies your JavaScript and CSS and also appends new unique(hash) values as the files change to invalidate cached versions.

Upvotes: 0

Riz
Riz

Reputation: 10246

use this code in block

<META HTTP-EQUIV='Pragma' CONTENT='no-cache'">
<META HTTP-EQUIV="Expires" CONTENT="-1">

or use any random number at the end of URLs.

I can see, what you can do is add a random in your JavaScript file’s reference every time. Just like the following code:

jsfilename.js?Math.random()

Then your js file cannot cache by browser.

if still not working, Follow up

http://verens.com/2008/04/09/javascript-cache-problem-solved/

Upvotes: 0

SShebly
SShebly

Reputation: 2073

add the following meta tag line to your header:

<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">

Upvotes: 3

Related Questions