aboutsummaryrefslogtreecommitdiffstats
path: root/includes/HTMLFileCache.php
diff options
context:
space:
mode:
authorIlmari Karonen <vyznev@users.mediawiki.org>2010-12-05 23:07:48 +0000
committerIlmari Karonen <vyznev@users.mediawiki.org>2010-12-05 23:07:48 +0000
commitabae23837d580761f2cdf67cdfffd454c69a5991 (patch)
tree51dcd7e45d7f9297f12c2f47ef471fe2d53ee9c8 /includes/HTMLFileCache.php
parentbb84043024456a910badcd43cc604c80be7bff94 (diff)
downloadmediawikicore-abae23837d580761f2cdf67cdfffd454c69a5991.tar.gz
mediawikicore-abae23837d580761f2cdf67cdfffd454c69a5991.zip
Add new config variable $wgFileCacheDepth to set the depth of the subdirectory hierarchy used for the file cache. Default value is 2, which matches former behavior. Setting this to 0 makes the paths simpler, and can be used with clever Apache rewrite rules to serve cached files directly without calling MediaWiki or PHP at all.
Notes
Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/77843
Diffstat (limited to 'includes/HTMLFileCache.php')
-rw-r--r--includes/HTMLFileCache.php15
1 files changed, 9 insertions, 6 deletions
diff --git a/includes/HTMLFileCache.php b/includes/HTMLFileCache.php
index 80744f766f73..e1671509e7e4 100644
--- a/includes/HTMLFileCache.php
+++ b/includes/HTMLFileCache.php
@@ -30,7 +30,7 @@ class HTMLFileCache {
public function fileCacheName() {
if( !$this->mFileCache ) {
- global $wgCacheDirectory, $wgFileCacheDirectory;
+ global $wgCacheDirectory, $wgFileCacheDirectory, $wgFileCacheDepth;
if ( $wgFileCacheDirectory ) {
$dir = $wgFileCacheDirectory;
@@ -42,14 +42,17 @@ class HTMLFileCache {
# Store raw pages (like CSS hits) elsewhere
$subdir = ($this->mType === 'raw') ? 'raw/' : '';
+
$key = $this->mTitle->getPrefixedDbkey();
- $hash = md5( $key );
+ if ( $wgFileCacheDepth > 0 ) {
+ $hash = md5( $key );
+ for ( $i = 1; $i < $wgFileCacheDepth; $i++ ) {
+ $subdir .= substr( $hash, 0, $i ) . '/';
+ }
+ }
# Avoid extension confusion
$key = str_replace( '.', '%2E', urlencode( $key ) );
-
- $hash1 = substr( $hash, 0, 1 );
- $hash2 = substr( $hash, 0, 2 );
- $this->mFileCache = "{$dir}/{$subdir}{$hash1}/{$hash2}/{$key}.html";
+ $this->mFileCache = "{$dir}/{$subdir}{$key}.html";
if( $this->useGzip() ) {
$this->mFileCache .= '.gz';