Problem with HTTP Caching...?

Posted on 16th Feb 2014 by admin

Hi there, im trying to implement caching. But it doesn't always work.
I post it here because there is no Client-Side HTTP topic...

Code: private function setLastModified ($aTimestamp) {
$this->addHeader('Last-Modified', gmdate('r',$aTimestamp), True);
}

private function setExpires ($aTimestamp) {
$this->addHeader('Expires', gmdate('r',$aTimestamp), True);
}

private function setPragma ($aPragma) {
switch ($aPragma) {
case conResponce_NO_CASHING: $this->addHeader('Pragma', 'no-cache', True); break;
case conResponce_PRIVATE: $this->addHeader('Pragma', 'private', True); break;
case conResponce_PUBLIC: $this->addHeader('Pragma', 'public', True); break; }
}

And this result in on the client-side:


http://localhost/CMS%20Test/index.php?type=4&html=test

Request Headers
Accept:application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Cache-Control:max-age=0
Referer:http://localhost/CMS%20Test/index.php
User-Agent:Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/532.0 (KHTML, like Gecko) Chrome/3.0.195.27 Safari/532.0


Response Headers
Cache-Control:public
Connection:Keep-Alive
Content-Type:text/html
Date:Tue, 10 Nov 2009 12:20:58 GMT
Expires:Tue, 10 Nov 2009 12:21:58 +0000
Keep-Alive:timeout=5, max=74
Last-Modified:Tue, 10 Nov 2009 12:07:03 +0000
Pragma:public
Server:Apache/2.2.11 (Win32) PHP/5.3.0
Transfer-Encoding:chunked
X-Powered-By:PHP/5.3.0


Is:
Expires:Tue, 10 Nov 2009 12:21:58 +0000 wright?

Or does it have to look like:
Expires:Tue, 10 Nov 2009 12:21:58 GMT

I'm using: gmdate('r',$aTimestamp) and it's on the PHP site. Also i found this in a PHP book, but a lot of code of the book and the php site doesn't work at all or not properly. Im i the only one with this problems?
And why don't they remove "examples" that doesn't work?


Thanx...

Other forums