I have been asked to work on a corporate website a previous employee had created. The site is on shared GoDaddy hosting. One of the first things I noticed (after the 140KB JPEG on the front page, which is now 22KB for no noticeable degradation) was that none of the HTML pages being served were getting cached. Turns out every PHP file on this website is sending the following headers:

Pragma: no-cache
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0

The 1981 expiry date is notable as it is an odd day/time to choose arbitrarily. This is not affecting other MIME types, just text/html (all of which are PHP-generated). As the server is running PHP 5.2 there's no header_remove() function. I have tried overriding them in PHP by using empty values:

header("Pragma: ");
header("Expires: ");
header("Cache-Control: ");

This didn't work. So I tried removing them via .htaccess:

<FilesMatch "\.php$">
  Header unset Pragma
  Header unset Expires
  Header unset Cache-Control

This also failed. I am beginning to suspect a GoDaddy shared hosting misconfiguration that I won't be able to fix :-/

Has anyone seen this before or got other ideas I can try?


You're correct the date is there to prevent caching. The specific date is just a silly bit of trivia, though.

You seem to be right about GoDaddy not allowing or ignoring some of these options, though apparently it can be managed via one of way-too-many methods of attacking it; seems weirdly conditional, though. Here's a KB article on enabling mod_expires, which is apparently off by default. Given it's official documentation, that's probably your best bet.

This blog post (from 2010) has a few other takes on this you might try if that still doesn't work.

  • The 'trivia' you linked to contained this gem: "The date is the birthday of the developer Sascha Schumann who added the code. From session.c: ..." -- So, it's added by PHP's session code. Brilliant. There's no need for sessions on these public facing pages. I have located and deleted the offending start_session() line, and now all my HTML pages get cached. Aug 31 '12 at 9:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.