Jump to content

Browser cached an accidentally served "index.php"

Recommended Posts

I just had an interesting issue. I suspect that the web host did something with apache which caused a short timeframe in which the "index.php" file was served instead of the PHP generated output.

Firefox found the correct response when it was available(or didn't ever receive the index.php file) , but Chrome and Edge seemed to cache the index.php file. When I tried the link via Chrome thereafter, the index.php would just download with the filename "download".

After clearing the cache and cookies, it was fine. but it took some time, worrying, and convo with support before I concluded that I had received an index.php and cached it.

Now, I'm wondering if there is anything I can do to fix the issue for anyone else affected by the issue other than telling them "clear your cache and cookies".


Anyone ever have similar experiences? Should we have a statement like:

Header("Cache-Control: max-age=3000, must-revalidate");

in our default index.php file?


Link to comment
Share on other sites


honestly, i doubt anything in the index.php file will change anything as in the case you describe you don't get the right one...
instead i would try something in the htaccess file, something like

<IfModule mod_headers.c>
    Header set Cache-Control "no-cache, no-store, must-revalidate"
    Header set Pragma "no-cache"
    Header set Expires 0

but even this, i'm not sure it will work for a client browser cached file as it will even not have a look at what happens server side before serving the page...

have a nice day

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...