Topic on Project:Support desk

Setting $wgCacheEpoch to 24 hours ago

10
Jonathan3 (talkcontribs)

I've recently set $wgUseFileCache = true. Would it be possible to have pages cached for a maximum of 24 hours by setting $wgCacheEpoch = date('YmdHis', strtotime('-24 hours'))?

I have Cargo query pages which I would probably be happy to have cached for that limited period. I know alternatives are to $wgUseFileCache = false again, or use MagicNoCache's __NOCACHE__ on the Cargo templates. Are there other options? Thanks. ~~~~

MarkAHershberger (talkcontribs)

Is your concern primarily the Cargo pages? @Yaron Koren is probably your best bet for answers.

Jonathan3 (talkcontribs)

Thanks for replying. The reference to Cargo was more as an explanation for not wanting to have the pages cached forever, as some page content changes without being edited/touched. I have DPL queries too and the same probably applies.

I was just wondering whether my proposed $wgCacheEpoch setting would work, whether it would work but itself waste time, or whatever. Jonathan3 (talk) 07:44, 12 February 2019 (UTC)

Jonathan3 (talkcontribs)

PS I asked Yaron and there are no Cargo-specific issues in relation to my query. Thank you. Jonathan3 (talk) 07:46, 12 February 2019 (UTC)

Ciencia Al Poder (talkcontribs)

If you want to update specific pages, you can schedule in cron a call to the purgePage.php script, that will reparse the page and apparently rebuild the file cache of that page.

Jonathan3 (talkcontribs)

Thanks. I just wanted to know if setting cache epoch as suggested would work. I guess it would and I just need to try it myself. Jonathan3 (talk) 00:29, 13 February 2019 (UTC)

Ciencia Al Poder (talkcontribs)

Setting $wgCacheEpoch to something that is constantly varying (It doesn't matter if the time is now or 24h ago), would have the same effect as disabling cache entirely, with the difference that the former will save the contents of every page on the cache but will never be used, slowing things even more.

See Manual:$wgMainCacheType for settings.

Jonathan3 (talkcontribs)

Thanks for your answer. I've just had a look at public function isCacheGood in FileCacheBase.php, and it seems to check the date of the cache against $wgCacheEpoch: $good = ( $timestamp <= $cachetime && $wgCacheEpoch <= $cachetime );. See the second part of the test quoted. Would this really disable cache entirely? Maybe I'm looking in the wrong place, though - can you help? Thanks. ~~~~

Ciencia Al Poder (talkcontribs)

You're right. I though it was doing an exact comparison, not for it being greater than a specific time. But I'm not sure if other parts of MediaWiki (parser cache) would handle this the same way.

Jonathan3 (talkcontribs)

It seems to work. I have a test page with just {{CURRENTTIMESTAMP}} which sometimes shows an old time but never more than 24 hours ago, and another test page with {{CURRENTTIMESTAMP}} and __NOCACHE__ which always shows the current time.