Page cache & event calendar

gushie - November 9, 2006 - 13:30

I have a website which doesn't change very often (weekly updates) and I have page cache enabled with a 5 minute minimum cache lifetime.

Is there a way to set a 'maximum cache lifetime' or automatically clear the cache at regular intervals?

The reason I ask is that I have an event calendar block on the page which colours in the current day of the month. The problem is there are times that a cached page from a couple of days ago is shown, so every anonymous user effectively gets sent back in time!

Thanks.

php code

jferjan - November 16, 2006 - 12:44

Right now i'm testing this code to clear cache.

<?php
global $base_root;
$this_page = request_uri();
cache_clear_all($base_root . $this_page);
?>

www.ferjan.net

And does it work?

MarcDo - November 30, 2006 - 23:28

I had the same problem (Drupal 4.7.4) with cache enabled, (anonymous) users were complaining that the calendar was at least a week old.

Disabled the cache, and problem was gone.
Doesn't the cache refresh itself on the (max) time you set it?

Thanks,
Marc

it works

jferjan - December 1, 2006 - 17:18

But where do you put that

Rotwang - March 19, 2007 - 21:18

But where do you put that code? If you put that into the content of a page that you don't want to be cached, it won't work, because that php will only execute when the page isn't cached.

If the page is cached, then drupal will just serve the end html, right? The php in the page won't execute if it's coming from cache.

That's the problem I have now.

Same here

Albion_Arg - April 2, 2007 - 15:53

I´ve got the same problem here. Do you know a workaround ?
Where does that code go ?

Possible workaround

Albion_Arg - April 2, 2007 - 16:12

I disabled the minimum cache lifetime and it seems to work. Try it out. Not a solution but at least works.

Disable the minimum cache lifetime?

zacamjo - June 15, 2007 - 21:16

As in, set it to none? I had it set to none and I was having this same problem. On the chance you meant setting it to something low (like 1-15 minutes), I've changed it to 15 minutes to see what happens.

 
 

Drupal is a registered trademark of Dries Buytaert.