At 2/20/2005 01:12 PM, Rowan Collins wrote:
On Sun, 20 Feb 2005 12:43:58 -0500, Sebastien BARRE
<sebastien.barre(a)kitware.com> wrote:
Hello,
In my extension callback, I tried the following code:
$wgOut->addMeta("http:Pragma", "no-cache");
$wgOut->addMeta("http:no-cache", NULL);
$wgOut->addMeta("http:EXPIRES", "TUES, 31 DEC 1996 12:00:00
GMT");
The problem is (possibly) that there are multiple levels of caching
within MediaWiki, some of which are completely independent of the HTTP
dialogue with the browser. Don't ask me what they all are, or how they
do work, but I gather that they are many and complex. :)
I think I nailed it though:
global $wgTitle;
if ($wgTitle)
{
$ts = mktime();
$now = gmdate("YmdHis", $ts + 60);
$ns = $wgTitle->getNamespace();
$ti = wfStrencode($wgTitle->getDBkey());
$sql = "UPDATE cur SET cur_touched='$now' WHERE cur_namespace=$ns AND
cur_title='$ti'";
wfQuery($sql, DB_WRITE);
}
Note that this code is slightly identical to Title::invalidateCache.
The difference here is that if I call invalidateCache in my extension code,
it sets cur_touched to 'now', *then* create the cache, so the cache is
newer than cur_touched anyway. The trick here is that I set cur_touched in
the future, something not too intrusive, let's say 'now' + 60 seconds,
provided that I expect the cache to be created within 60 or 120 secs once
my extension code has been executed. That way, cur_touched is always
fresher than the cache, and the page always gets re-created. Am I missing
something ?
I also throw the following code that I found on various threads. Does not
hurt I guess.
global $wgOut;
$wgOut->enableClientCache(false);
$wgOut->addMeta("http:Pragma", "no-cache");
$wgOut->addMeta("http:no-cache", NULL);
$wgOut->addMeta("http:EXPIRES", "TUES, 31 DEC 1996 12:00:00
GMT");
--
Sebastien Barre