Question

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");
    
Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top