User:0x99/MediaWiki Patches

From Puella Magi Wiki
Jump to navigation Jump to search

Image cache

Puella Magi Wiki is using a far future expiration header to help with page load and bandwidth usage however when re-uploading the file MediaWiki will replace the same URL and user won't get the latest version of the file until the file is expired from user's cache. This patch add a timestamp to every image URL. It is based on a patch by Surgey Chernyshev.

includes/filerepo/File.php

--- File.old.php	2012-02-26 10:45:34.000000000 +0000
+++ File.php	2012-02-26 09:51:09.000000000 +0000
@@ -170,7 +170,7 @@
 		if ( !isset( $this->url ) ) {
 			$this->url = $this->repo->getZoneUrl( 'public' ) . '/' . $this->getUrlRel();
 		}
-		return $this->url;
+		return $this->url . "?" . $this->getTimestamp();
 	}
 
 	/**
@@ -788,7 +788,7 @@
 		if ( $suffix !== false ) {
 			$path .= '/' . rawurlencode( $suffix );
 		}
-		return $path;
+		return $path . "?" . $this->getTimestamp();
 	}
 
 	/** Get the virtual URL for an archive file or directory */