Forum Moderators: coopster
I am new to caching dynamic pages. All I knew was how to avoid caching.
My dynamic pages have on top of them an html header which shows the status of the user logged/not logged.
I would like to cache the pages and force re-cache if there is a change in the user's status.
I guess the must-revalidate has to be always present. I use
a last modified date which comes form my database. I think
Cache-Control: must-revalidate depends on the last modified date... am I right?
Should I change that modified date to the time the user logs off or on?
Is it ethical checking the user agent for bots? When dealing
with bots should use the real last modified date
thanks
What exactly do you want to have the site behaviour be?
Why control the caching that way for dynamic pages in that particular way? I understand caching of dynamic pages but when I read your post I seem to not be able to fully grasp the behaviour you desire.
The layout of all the pages contains a header revealing the user's status. That is, visitor, request in progress, logged. See what I mean? If a visitor watches an advise and aferwards logs, when he gets back the page is on his cache, but the header is wrong, shows status=visitor. It is not only the status, there is some different html also.
btw thanks for your answer
I don't know much about the IFRAME element. I've been taking a look a google's adwords code executing some caching tests. That could work for me, placing the code inside a portlet.
I'm using the following code.
define("UAROBOTS", "inktomi¦Googlebot¦ia_archiver¦FAST\-WebCrawler¦ZyBorg¦psbot¦updated
¦IRLbot¦Scooter¦Faxobot¦appie¦msnbot¦Mediapartners\-Google\/2\.1
¦Slurp¦Jeeves¦Teoma");
//database real date
$upd_time= strtotime($r[2]);
if (preg_match("/".constant("UAROBOTS")."/i", $_SERVER['HTTP_USER_AGENT']))
{
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) & (strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE'])>=$upd_time))
{
header ('Date: ' . gmdate ('D, d M Y H:i:s') . ' GMT');
header('HTTP/1.0 304 Not Modified');
exit;
}
else
{
header("Last-Modified: ".$upd_time);
header("Cache-Control: max-age=2592000");
header("Expires: " . gmdate("D, d M Y H:i:s", time() + 10000). " GMT");
}
After some usage I have noticed I am not giving any 304 back. I have tested it with the cacheability engine and works fine (adding its ua). The main problem seems to be that $_SERVER['HTTP_IF_MODIFIED_SINCE'] is always empty when dealing with real bots. I have tried it with get_apache_headers() but I'm not getting the if-modified-since header either. I use adwords, and the Mediapartners-Google/2.1 comes on the same page but doesn't send if-modified-since.
My server is apache2, it manages the caching of images, js, and kind of only inside certain directories. I am using sessions wich aren't started when user is a bot. No output buffering.
Thanks
[edited by: ergophobe at 2:30 pm (utc) on Feb. 14, 2005]
[edit reason] fixed sidescroll [/edit]