Forum Moderators: coopster

Message Too Old, No Replies

caching dynamic pages dependant on user status

caching pages when not logged / logged

         

Juanse

1:33 pm on Feb 8, 2005 (gmt 0)

10+ Year Member



Hi,

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

jatar_k

7:24 pm on Feb 9, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I don't really see what you are trying to do. Actually that's not true I get a rough idea but I am not sure of the 'why'.

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.

Juanse

8:06 pm on Feb 9, 2005 (gmt 0)

10+ Year Member



My pages contain ads which lie on a database. They have a last modified date. All of them can be chached setting the last modified date accordingly.

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

jatar_k

11:21 pm on Feb 9, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



unfortunately, I think I would just not cache them in this instance.

Why do you specifically need to cache them?

Juanse

7:31 am on Feb 10, 2005 (gmt 0)

10+ Year Member



Well, I think caching can be a good idea because there is realy a date I can rely on (we shouldn't always think in visual terms). It can be good for the three of us, users, servers and search engines.

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.

jatar_k

7:33 pm on Feb 10, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



actually that might just fit the bill, very good idea.

Juanse

10:56 am on Feb 14, 2005 (gmt 0)

10+ Year Member



Any help is greatly appreciated

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]