This guide explains how to clear the page cache in MediaWiki, which forces the wiki to regenerate a page’s HTML output from the latest source. This is useful when you’ve edited a page or a template and the changes aren’t showing up for visitors, or when you’ve modified site CSS/JS and need to refresh the cached versions. You’ll learn several methods, from the simplest (for a single page) to the most thorough (for the entire wiki).
What You’ll Need
- Access to your MediaWiki installation’s files (via FTP, SSH, or a file manager) — needed for some methods.
- If you want to purge the cache for all pages, you’ll need shell (SSH) access or a way to run PHP scripts on the server.
- For some methods, you’ll need to know the exact page title (e.g., “Main Page”).
Step-by-Step
Method 1: Purge a Single Page (Quickest)
- Navigate to the page you want to refresh in your browser.
- Add
?action=purgeto the end of the URL. For example:https://yourwiki.org/wiki/Main_Page?action=purge - Press Enter. MediaWiki will clear the cached HTML for that page and regenerate it on the next view.
- If you’re not logged in, you may see a confirmation prompt. Click “OK” or “Yes” to proceed.
Method 2: Purge via the Edit Tab (for Users with Edit Rights)
- Log in to your wiki with an account that has edit permissions.
- Open the page you want to refresh.
- Click the “Edit” tab at the top.
- Make a trivial change (like adding a space) or simply click “Save page” without changing anything. MediaWiki will purge the cache for that page.
Method 3: Clear the Entire Page Cache (via Maintenance Script)
- Access your server via SSH (or a terminal in your hosting control panel).
- Navigate to your MediaWiki installation directory (where
LocalSettings.phpis located). - Run the maintenance script to rebuild the cache for all pages:
php maintenance/rebuildrecentchanges.phpThis script rebuilds the recent changes cache, but it also clears the page cache for all pages. It’s safe to run and often the recommended way to refresh everything.
- If you want to specifically clear the object cache (used for parser cache, etc.), you can run:
php maintenance/rebuildall.phpThis rebuilds all caches, including the parser cache, and is more thorough.
Method 4: Clear the Cache via the API
- For a single page, you can use the API endpoint:
https://yourwiki.org/api.php?action=purge&titles=Page_Title(replacePage_Titlewith the actual title, using underscores for spaces). - You may need to authenticate if the wiki requires login for purging.
Method 5: Clear the Cache via PHP (for Developers)
- If you have shell access, you can run a one-liner PHP script to clear the cache for a specific page:
php -r "require 'includes/WebStart.php'; \$title = Title::newFromText('Main Page'); \$page = WikiPage::factory( \$title ); \$page->doPurge();" - This is a more advanced method and requires familiarity with the MediaWiki codebase.
Common Mistakes
- Forgetting to use the exact page title — the purge action is case-sensitive. “Main_Page” and “Main page” are different.
- Only clearing your browser cache — this helps only you, not other visitors. The wiki’s server-side cache is what matters.
- Not checking if the wiki uses a reverse proxy or CDN — if you use Varnish, Cloudflare, or similar, you may need to purge the cache there as well, as the MediaWiki purge only clears the application cache.
- Running the wrong maintenance script —
rebuildrecentchanges.phpis for recent changes, but it also clears the page cache. If you only want to clear the page cache,rebuildall.phpis more direct.
Tips
- For frequent editors, adding
?action=purgeto your browser’s bookmark for the page is a handy shortcut. - If you have a large wiki, purging all pages at once can cause a spike in server load. Consider doing it during off-peak hours.
- Use the
action=purgemethod for individual pages after edits; it’s instant and doesn’t require shell access. - If you’re using a CDN, you may need to purge the CDN cache separately. Many CDNs offer a purge API or a control panel option.
- If you’re editing templates or CSS, remember that pages that transclude the template may still show old versions until they are purged. You can purge a page that uses the template to force it to update.
Troubleshooting
- Page still shows old content after purge — If you’ve purged the MediaWiki cache but the page still looks old, check if you have a reverse proxy (like Varnish) or a CDN in front of your wiki. Purge that cache as well. Also, check if your browser is caching the page (try a hard refresh: Ctrl+F5 or Cmd+Shift+R).
- You get a “Permission denied” error when using ?action=purge — Some wikis restrict the purge action to logged-in users. Log in and try again. If you’re an admin, check the
$wgGroupPermissionssettings in LocalSettings.php. - Maintenance script fails with a PHP error — Ensure you’re running the script from the MediaWiki installation directory and that PHP is available in your environment. Check that your PHP version is compatible with your MediaWiki version.
- Changes to a template don’t appear on pages that use it — Even after purging the template page, the pages that transclude it may still have cached versions. You need to purge each of those pages, or use the
?action=purgeon a page that includes the template. Some wikis have a “Purge” link in the sidebar for this purpose. - Cache seems to clear but then immediately becomes stale — This can happen if you have an opcode cache (like APC or OPcache) that is caching the PHP files. Clear that cache as well (usually via a control panel or by restarting the web server).
Frequently Asked Questions
Does clearing the page cache delete any page content?
No. The cache only stores the rendered HTML output. The actual wiki source (wikitext) is stored in the database and is never touched by cache clearing.
How often does MediaWiki automatically clear the page cache?
MediaWiki automatically purges a page’s cache when the page is edited. It also expires cache entries after a certain time (default is 24 hours, but this can be changed with $wgParserCacheExpireTime).
Can I clear the cache for all pages at once without shell access?
Yes, by using the action=purge on each page, but that’s tedious. Some wikis have a special page like Special:Purge (if the extension is installed). Otherwise, you need shell access to run maintenance scripts.
What’s the difference between ?action=purge and ?action=flush?
?action=purge clears the parser cache for that page. ?action=flush is a more aggressive action that also clears the compiled templates and other low-level caches for the page. In most cases, purge is sufficient.
Will clearing the cache affect all users or just me?
Clearing the MediaWiki cache affects the server-side cache, so all users will see the updated page on their next visit. Clearing your browser cache only affects your own browser.
Is there a way to disable the page cache entirely?
Yes, you can set $wgParserCacheType = CACHE_NONE; in LocalSettings.php, but this is not recommended for production wikis as it significantly increases server load.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.
More cards in this drawer
- Campus Tech Innovation Hubs: What They Are
- Poco C51 Airtel Prepaid Locked Variant India?
- Jenkins vs GitHub Actions: Which CI/CD Fits Your Team?
- Turn Off Backup Encryption in iTunes?
- Shared VPS Hosting: Is It Better?
- Disk Defrag Pro: What It Does and Whether You Need It