Cache-Control HTTP header question


#1

Hi all,
When back-button is used, my site displays the dreaded ‘Webpage is Expired’ screen (and when the page is reloaded all form values are lost). I’m trying to avoid this.

I’ve tried adding the ‘Cache-control: public’ HTTP header, and this seemed to work well on my localhost wamp server.

[font=Courier]session_cache_limiter(‘public’);
session_start();
header( ‘Cache-control: public’);
header(“expires: -1”);[/font]

However on my dreamhost server, it does not work. I used ieHTTPHeaders to display the HTTP headers, and found that there are two Cache-control HTTP headers, the one I added (‘Cache-control: public’), as well as a default one (‘Cache-control: max-age=0, no-cache, no-store’).

[font=Courier]HTTP/1.1 200 OK
Date: Fri, 13 May 2011 03:25:26 GMT
Server: Apache
Cache-control: public
expires: -1
Set-Cookie: PHPSESSID=CyOQvQdu8GKp%2C93loU7yX1; path=/
X-Mod-Pagespeed: 0.9.15.3-404
Cache-Control: max-age=0, no-cache, no-store
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 1762
Keep-Alive: timeout=2, max=100
Connection: Keep-Alive
Content-Type: text/html[/font]

Does any one know where this extra ‘Cache-control: max-age=0, no-cache, no-store’ HTTP header is coming from and how to remove it?
Thanks!
Dave


#2

Where is “expires: -1” coming from? Aside from being invalid (the value of Expires must be a valid HTTP date), that will likely inhibit the browser from reusing a cached page, regardless of any other settings.

I’m not sure what would be generating the extra Cache-Control header, but mod_pagespeed is a likely culprit. Try turning that off.


#3

Many thanks, that worked.
(I unchecked the Dreamhost ‘Page Speed Optimization’ in the domain hosting option page).