Prevent Apache pages with 304 status code

I have a server, LAMP, setup and CakePHP application. When I request a web page through any web browser, it always responds with a 304 status, serving old pages even after I have changed the page. It seems that the server stores any previously available page in a cache and returns it to anyone who requests it. For example: user "X" logs in to this system and accesses the "home" page and logs out. When another user "Y" logs in, he will see "X" "home", whereas he should be able to access his home page with his name. Instead, he sees that X has already spoken to him. When I completely delete a resource, say the "home" page, it might still be available.I checked and pages are served with 304 unchanged status code; However, I was unable to change this behavior in my apache settings; I am a beginner and I have no solutions. Any help would be much appreciated here.

0


source to share


1 answer


If anyone else has a problem, I'll answer my own question. I found a potential reason for this behavior. My apache settings are fine, but my lan has an Apache traffic server that caches some resources, things like images and css files are cached by default. If a change has been made to the file, it is recommended that you rename it so that the old file is not uploaded. For web pages, I made them not cache by adding the following:

<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="cache-control" content="no-store" />
<meta http-equiv="cache-control" content="must-revalidate" />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="expires" content="0" />

      

Since I was using cakePHP, I also added the following lines to my beforeFilter method of the AppController file ( here) :



function beforeFilter() {

    /**
     * /questions/2189749/cakephp-caching-issue-when-redirecting-back-to-same-page
     */

    header('Cache-Control: no-cache, no-store, must-revalidate');
    header('Pragma: no-cache');
    header('Expires: 0');

}

      

I hope this helps someone.

0


source







All Articles