Cache Control in Apache 2+php module

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
thisbl00d
Forum Newbie
Posts: 13
Joined: Sat Feb 14, 2009 1:17 pm

Cache Control in Apache 2+php module

Post by thisbl00d »

What does the code below interpret? can some1 explain in detail

Code: Select all

// Work around for "current" Apache 2 + PHP module which seems to not
// cope with private cache control setting
if (!empty($HTTP_SERVER_VARS['SERVER_SOFTWARE']) && strstr($HTTP_SERVER_VARS['SERVER_SOFTWARE'], 'Apache/2'))
{
    header ('Cache-Control: no-cache, pre-check=0, post-check=0');
}
else
{
    header ('Cache-Control: private, pre-check=0, post-check=0, max-age=0');
}
header ('Expires: 0');
header ('Pragma: no-cache');
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Cache Control in Apache 2+php module

Post by requinix »

It doesn't interpret anything. And if you want to be taken seriously, for God's sake, spell out "someone" instead of using txt tlk.

Cache-Control is a way to control the browser's caching. Apparently the developer thought there was an issue with Apache 2 (may be, may not be) so there's a workaround.
If the server is running Apache 2 then PHP will send one version of the header, otherwise it'll send a slightly different version. Then it sends a couple more headers. All of the above tell the browser to not cache anything.
Post Reply