Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Update an html file so that the browser knows not use the one in the cache

I thought I was having an issue with my javascript being cached and not updated even with an updated version tag, like:

<script type="text/javascript" src="lib/myScript.min.js?v=3"></script>

But I realized that the problem is with my html file is being cached... so the browser doesn't even know there is a new script file.

I don't want to disable caching, but isn't there a way to let the browser know it doesn't have the most up-to-date html file? (And is this something I'd put in my html file, or on my apache2 server?)

like image 270
Sam Mirrado Avatar asked Sep 05 '12 10:09

Sam Mirrado


2 Answers

<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />

Answer from Using tags to turn off caching in all browsers?

like image 100
Eirik H Avatar answered Nov 18 '22 09:11

Eirik H


You can try these meta tags.I think it will solve your problem.

<meta http-equiv='cache-control' content='no-cache'>
<meta http-equiv='expires' content='0'>
<meta http-equiv='pragma' content='no-cache'>
like image 3
Gokcen Avatar answered Nov 18 '22 11:11

Gokcen