I have a feature on a mediawiki site that updates the home page every day based on current date. Problem is: browser caching is causing the page to not be updated for returning users. Is there a way to fix this?
Thx, LainieH
The safest way is to serve your pages via https (note the "s"), because most browsers will delete everything they recieve via https after they are closed and the session is ended (bank websites work with this). You'll need an SSL certificate for this, but some hosting packages come with a free certificate, so you may have one.
More practically (and if you do not need to uncache sensitive data), you can also put these meta tags in the header of your pages: <meta http-equiv="Pragma" content="no-cache"> <meta http-equiv="Expires" content="Mon, 20 Dec 1998 01:00:00 GMT"> The date can lie in the past (deprecated but works) or be generated by PHP to lie in the very near future (e.g. five minutes after the page is being served). These tags work only, if the browser respects them. Google a bit to find which browsers and which browser versions do not respect them.
You can also send the same info to the browser as headers:
header( "Expires: Mon, 20 Dec 1998 01:00:00 GMT" ); header( "Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT" ); header( "Cache-Control: no-cache, must-revalidate" ); header( "Pragma: no-cache" );
These headers are sent BEFORE the HTML and not displayed in the source code, but they are identical to the meta tags (compare the "Pragma" tag I gave above and the "Pragma" header below). I guess browsers take headers more seriously than tags (because they feel they are talking to another server, not just displaying some faulty code written by some n00b), but I don't know.
Google a bit around this quick info and "prevent browser caching" to get more info on this.
I have a feature on a mediawiki site that updates the home page every day based on current date. Problem is: browser caching is causing the page to not be updated for returning users. Is there a way to fix this?
Thx, LainieH
MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
mediawiki-l@lists.wikimedia.org