0

I have question regarding disabling browser caching. I have already found few solutions, and just want to know if there are better or more common approaches. So I have GWT applications and in order to disable cashing I may use next options:

  1. Adding to URL dummy parameter
  2. Putting on the HTML page <meta http-equiv="pragma" content="no-cache">
  3. Setting HTTP headers:

    header("Pragma-directive: no-cache");  
    header("Cache-directive: no-cache");  
    header("Cache-control: no-cache");  
    header("Pragma: no-cache");  
    header("Expires: 0");
    
3
  • It is already asked I guess. check this link Commented Apr 9, 2012 at 11:23
  • 1
    The headers you list include some fantasy/wishful thinking. Expires:0 is a syntax error, *-directive are nonsense, Pragma: no-cache is irrelevant since end of '90s. The only one that matters is Cache-control: no-cache. <meta> cannot work, since it's cached before it is parsed. Commented Apr 9, 2012 at 11:28
  • So, i should use first option? But this is most inconvenient way for me. I'd rather use option number 3. Commented Apr 9, 2012 at 11:32

1 Answer 1

2

The most important are the

header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");  #Expires sometime in the past
header("Cache-control: no-cache");                 #Disables caching

In addition, add the unique parameter to the url to be sure. If you are using browser back-button sometimes the entire DOM is cached and no new content is fetched unless you do it dynamically using javascript and adding a unique id to your request.

Normally, you want to set most of these headers in your server configuration so that you can serve normal images and other static content with the right headers also.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.