[TYPO3-dev] Core Behaviour: Using Cache-Control Headers to prevent _Clients_ from Caching

Ekkehard Gümbel guembel.remove-this at naw.de
Mon Nov 20 21:29:39 CET 2006


Hi,
I am struggling to prevent my friend the IE from caching locally...

Normally, that is done using HTTP headers. TYPO3 supports these with the "sendCacheHeaders" config option.
And it behaves just like TSRef says: "In case caching is not allowed, these headers are sent to avoid client 
caching: Cache-Control: private"

Now "Cache-Control: private" is fine for regular proxy caches but not for client side caching (see 
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html).

Funny thing is, that in class.t3lib_userauth.php an undocumented (?) additional option called 
"sendNoCacheHeaders" seems to take care of this issue.

Extending this concept to class.tslib_fe.php is solving my problem - see code below.
(Another option would of course be to skip the "sendNoCacheHeaders" switch and make this behaviour always-on - 
but are of course cases where you want to prevent shared-caching but allow client-side caching. In fact this 
was Ole Tange's sole intention as he just told me.)

Does this make any sense to someone?

Cheers
/Ekki



##### snip (class.tslib_fe.php) #####
$this->isClientCachable = TRUE;
} else {

// Build headers
if ($this->config['config']['sendNoCacheHeaders'])  {
         // Send various headers to prevent all proxy or client-side caching
         $headers = array(
                 'Pragma: no-cache',
                 'Cache-Control: private, must-revalidate, no-store',
                 //'Expires: 0',   // unsave with HTTP/1.0 clients
                 'Expires: Thu, 01 Dec 1994 16:00:00 GMT',
         );
} else {
         // prevent shared-caching (a.k.a. proxy caching)
         $headers = array(
                 'Cache-Control: private',          // Changed to this according to Ole Tange, FI.dk
         );
}

$this->isClientCachable = FALSE;
##### snip #####




More information about the TYPO3-dev mailing list