Skip to main content
Known Participant
March 6, 2017
Answered

how to force browser to load fresh copy every time

  • March 6, 2017
  • 4 replies
  • 55941 views

When I update a web page for a client, I get tired of telling them to load the page which is usually the previous web page version and then tell them to hit the browser refresh button.  Two questions: 

1.  Can I add code to have the latest page always loaded?

2.  If you don't hit the refresh button, how long does it take for a browser to finally load this new page, a day, 2 days, etc.

Thanks.

Don

This topic has been closed for replies.
Correct answer pziecina

Add the following in your head content -

<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />

Don't forget to remove before the page goes live.

4 replies

Nancy OShea
Community Expert
Community Expert
March 6, 2017

You could send this link to your clients.

Secrets of the Browser Developer Tools - Disable the Browser Cache

Nancy

Nancy O'Shea— Product User & Community Expert
OhAdobeYouSoCrazy
Inspiring
March 6, 2017

pziecina's answer above is the correct official answer.

If you are looking for something to supplement that for a browser with a sticky cache... I often have luck appending a query string to the address. The below javascript would crawl all the images on the page and force them to get refreshed versions by appending the Linux timestamp onto the query string.

<script type="text/javascript">
$(document).ready(function(){
  $
('img').each(function(){

      var date = new Date;
     
// add the current unix timestamp in microseconds to the the image src as a query string
     
this.src = this.src + '?' + date.getTime();
  
});

});
</script>

Jon Fritz
Community Expert
Community Expert
March 6, 2017

I've used similar scripts to avoid caching in the past.

In my experience, they've worked more reliably than the <meta> options available.

Nancy OShea
Community Expert
Community Expert
March 6, 2017

https://forums.adobe.com/people/Jon+Fritz+II  wrote

I've used similar scripts to avoid caching in the past.

In my experience, they've worked more reliably than the <meta> options available.

My husband insists on using a NoScripts addon in his browsers (an endless source of irritation, beleive me).  So, JS solutions don't always work either.

This article discusses various methods and their pros & cons.

Preventing Browser Caching | Tiger Technologies Support

And their disclaimer at the bottom says,

"The tips above will work in almost all cases, but the nature of the Internet means you can't guarantee it will always work the way you hope."

Nancy

Nancy O'Shea— Product User & Community Expert
Nancy OShea
Community Expert
Community Expert
March 6, 2017

If you find a reliable cross browser way to make this work, let me know.  

The no-cache & pragma meta is not 100% reliable.

Sometimes I use expired and last-modified date & time in my header.  In theory, the browser is supposed to compare the cached version with the server version and display the latest one.    But that's not 100% either.

Nancy

Nancy O'Shea— Product User & Community Expert
pziecina
pziecinaCorrect answer
Legend
March 6, 2017

Add the following in your head content -

<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />

Don't forget to remove before the page goes live.