I have an issue where the newest content of a local HTML file is sometimes not displayed. Instead, the browser shows a cached version. The workaround is to press <Ctrl>+<F5> but I'd like to resolve this programmatically.
Specifically, I download an HTML file and open it in my browser. Later I download a newer version of the file (with the same file name). The newer file has different content but some browsers, sometimes still show the old content from the cache. I'm having trouble consistently reproducing the error but when it occurs it's very irritating.
I've found two possible solutions but because of the difficulty reproducing the error, I can't confirm that either of them are correct.
One possible solution is the following Javascript:
<script type="text/javascript">
window.location.reload(true);
</script>
Another is the following metatags:
<META HTTP-EQUIV="Expires" CONTENT="Tue, 01 Jan 1980 1:00:00 GMT">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
Is it this simple? If so, does it work for Ch, IE & FF?
Is there a totally different solution that I've missed?
no-cachemetatags? And updating the source of the downloaded file each time seems like a lot of effort. – Ciaran Aug 17 '11 at 14:23