[MediaWiki-l] Short URL + Directly serve from file cache

Iso Bar openshift.isobar at gmail.com
Sat Jul 15 18:13:11 UTC 2017


I tried to follow the instructions to serve from file cache directly (link
and to have short url (link

But those two instructions don't seem to be directly compatible. How should
I write the .htaccess file at the web root?

The php7 at the host is slow, so I want to minimize number of redirects /
avoid php.

Current .htaccess at the webroot:

# Enable the rewrite engine
RewriteEngine On

# Short url for wiki pages
# RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/w/index.php [L]

# Redirect / to Main Page
# RewriteRule ^/*$ %{DOCUMENT_ROOT}/w/index.php [L]

# Serve directly from cache
RewriteBase /
# If a cached page exists under /w/html_cache, do an internal redirect to
RewriteCond %{HTTP_COOKIE} !UserID=
RewriteCond %{QUERY_STRING} !.
ReWriteCond %{THE_REQUEST} ^GET\x20/wiki/([^\x20/]+)\x20HTTP
RewriteCond %{DOCUMENT_ROOT}/w/html_cache/%1.html -s
RewriteRule ^wiki/(.+)$ /w/html_cache/%1.html [B,L,NS]

# Redirect / to cached Main Page
RewriteRule ^/*$ %{DOCUMENT_ROOT}/w/html_cache/Main_Page.html [L]

Permissions for Folders:

0700    web_root/w/cache
0755    web_root/w/html_cache
0755    web_root/w/images


$wgMessageCacheType = CACHE_ACCEL;
$wgUseFileCache = true;             // Enable file cache
$wgCacheDirectory = "$IP/cache";
$wgFileCacheDirectory = "$IP/html_cache";
$wgDisableOutputCompression = true; // already used mod_deflat
$wgUseLocalMessageCache = false;
$wgParserCacheType = CACHE_DB;
$wgEnableSidebarCache = true;

$wgDisableCounters = true;
$wgMiserMode = true;

$wgRevisionCacheExpiry = 3*24*3600;
$wgParserCacheExpireTime = 14*24*3600;

# Serve directly from cache
$wgFileCacheDepth = 0;

Thanks again.

More information about the MediaWiki-l mailing list