0

I need the ability to force reload of cache when a user goes to my page (for a few reasons) and I have seen ways to do this with server side code but I am using a hosted CMS and do not have the ability to use server side code. Is there a way to do this with javascript alone?

Or should I use something like myjavascript.js?=v1 on all of my css and js files?

what is the best method?

Cœur
  • 37,241
  • 25
  • 195
  • 267
L84
  • 45,514
  • 58
  • 177
  • 257
  • So you want js to put in the page to reload itself without using the cached version. Is that correct? – JohnFx Sep 15 '11 at 02:58
  • see http://stackoverflow.com/questions/1011605/clear-the-cache-in-javascript – Kevin Hakanson Sep 15 '11 at 02:59
  • I want the entire site to be reloaded. I do not want a cached version of my site being used for a bit (I have a few reasons but I am not going to explain here) – L84 Sep 15 '11 at 02:59
  • Not sure what you mean. When a browser visits a site only one page is loaded at a time. Are you trying to clear the browser cache, or just ensure that a cached version of any page on the site is never used? – JohnFx Sep 15 '11 at 03:01
  • Cache is managed by the server environment. You need to look into ways to defeat a server's cache protocols, and incorporate that into the client-side request to the server. – Jared Farrish Sep 15 '11 at 03:03
  • I want to ensure that if a person has visited the page before the cached version is not used and they are forced to download a new version of the site (or the page they are visiting) – L84 Sep 15 '11 at 03:03
  • @Jared how is this done, can you give me an example? – L84 Sep 15 '11 at 03:03
  • You are trying to prevent browser caching? There are dozens of ways to do that all with different pros and cons. This is a duplicate of dozens of questions on the site. Just search for "prevent browser caching" – JohnFx Sep 15 '11 at 03:06
  • That would depend on how the server was managing the server environment. Some answers have already been provided. – Jared Farrish Sep 15 '11 at 03:06
  • possible duplicate of [What is an elegant way to force browsers to reload cached CSS/JS files?](http://stackoverflow.com/questions/118884/what-is-an-elegant-way-to-force-browsers-to-reload-cached-css-js-files) – JohnFx Sep 15 '11 at 03:06
  • Tell the user to press Ctrl + F5 by themselves. – Derek 朕會功夫 Sep 15 '11 at 03:16

1 Answers1

2

You could use an HTML meta tag, something like

<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache"> 
rumspringa00
  • 132
  • 1
  • 12