QUERY: If-None-Match / ETag caching for Content Pages
Posted: Wed May 31, 2006 2:01 pm
I've found that this works just fine in Firefox on Content pages, if you add this code to index.php near the bottom (just above the "echo $html" statement):-
For non-Apache servers, you also need emu_getallheaders - see earlier thread.
What's puzzling me is that this works just fine for Firefox, but MSIE just doesn't take any notice. IE just doesn't send the "If-None-Match:" header the second time it fetches a page, even though it all works just fine for style sheets.
Has anyone got content caching to work in IE ?
Code: Select all
#Do cache-control stuff
if (function_exists('getallheaders'))
$headers = getallheaders();
else
$headers = emu_getallheaders();
$hash = md5($html);
#if browser sent etag and it is the same then reply with 304
if (isset($headers['If-None-Match']) && $headers['If-None-Match'] == '"'.$hash.'"')
{
header('HTTP/1.1 304 Not Modified');
exit;
}
else
{
header('ETag: "'.$hash.'"');
};
echo $html;
What's puzzling me is that this works just fine for Firefox, but MSIE just doesn't take any notice. IE just doesn't send the "If-None-Match:" header the second time it fetches a page, even though it all works just fine for style sheets.
Has anyone got content caching to work in IE ?