I have a problem where corporate proxy servers serves up the page for different logged in users. I reckon I can solve this issue by disabling proxy caching. This page suggests including the following snippet in htaccess:
ExpiresDefault A0
Header set Cache-Control "no-store, no-cache, must-revalidate, max-age=0"
Header set Pragma "no-cache"
As I've understood it (by Googling), the Expires header is only read by proxies, so I might also just use "Header set Expires 0"?
I suppose this would also prevent caching of stylesheets, images and other assets (although only by proxies, not browsers)?
What is the best way to deal with this? I'm running PHP, and can easily modify headers through PHP, too, if that's recommended.
I don't have access to a proxy server for testing.
Use:
From http 1.1 spec (RFC 2616) chapter 14.9.1
Header set Cache-Control "private, ..." does the trick.
There is no need for the Expires header. Cache-Control: max-age overrides the Expires field. See RFC Section: 14.21
You should send different caching headers depending on the content you deliver.
The following example is for a website delivering static contents in /static and vary content for logged in users. Logged in users are identified by presence of the session cookie: MYSESSID.