Help:File cache

From lensowiki

Jump to: navigation, search

Mediawiki supports a basic file cache for static pages for non-logged-in visitors. When an anonymous user requests a page it is constructed from the database, and also stored in the cache. When the same page is requested later on, it is directly served from the cache, without the need to query the database. This will reduce the database and server load on public sites.

Enabling the cache

The file cache is enabled by setting these variables in LocalSettings.php:

$wgUseFileCache = true;
$wgFileCacheDirectory = "/tmp/yourcache";
$wgShowIPinHeader = false;
$wgUseGzip = false;

Setting $wgShowIPinHeader to false is required. Since the cache serves the same page to many visitors, it's not possible to include the unique IP number of the current visitor in the page.

Setting $wgUseGzip to false is currently (1.3.0beta6) required to workaround a bug. This implies that files are cached and sent over the wire uncompressed (saves CPU cycles, at the cost of bandwith).

You need to manually create the top level cache directory and make sure Mediawiki can write to it:

mkdir -p /tmp/yourcache
chmod 777 /tmp/yourcache -R

Mediawiki will automatically create a two-level directory structure in the cache directory, to improve performance of file retrieval from the cache.

You can see that the cache works by repeatedly refreshing a page with a visitor counter. Even with a forced reload (Shift-Reload in mozilla or Ctrl-Shift-Refresh in Internet Explorer) the counter will not increment.

Limitations

Todo

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox