From ThirdMartini

[edit] Introduction

The nocache extension prevents wikipedia from storing this page into the database cache. It is useful when combined with other extensions that provide refresh-time display widgets.
Copy the extension into your extensions directory and add the line include("extensions/nocache.php") to your LocalSettings.php file

[edit] Code

<?php
include_once("DatabaseFunctions.php");

$wgExtensionFunctions[] = "rbdNoCache";
 
// ------------------------------------------------------------------------ 
function rbdNoCache() 
{
  global $wgParser;
  $wgParser->setHook( "nocache", "rbdNoCacheCall");
}
 
// ------------------------------------------------------------------------ 
function rbdNoCacheCall($input)
{
	global $wgTitle, $wgOut;
	if (!isset($wgTitle) || !isset($wgOut))
	{
		return;
	}

	$ts = mktime();
	$now = gmdate("YmdHis", $ts + 120);
	$ns = $wgTitle->getNamespace();
	$ti = wfStrencode($wgTitle->getDBkey());

	if ( $options ) {
		$db =& wfGetDB( DB_MASTER );
	} else {
		$db =& wfGetDB( DB_SLAVE );
	}


	$page = $db->tableName( 'page' );
	$sql = "UPDATE $page SET page_touched='$now' WHERE page_namespace=$ns AND page_title='$ti'";
	wfQuery($sql, DB_WRITE, "rbdNoCache");
	return "";
}


?>
Personal tools