Extension:Cloudflare
Cloudflare Release status: beta |
|
---|---|
Implementation | other (invalid type) |
Description | Purge Cache for CloudFlare. |
Author(s) | Harugon1talk |
Latest version | 0.1.3 |
MediaWiki | >= 1.35 |
PHP | 7.4+ |
Database changes | No |
Composer | harugon/cloudflare |
License | MIT License |
Download | Download snapshot Note: README |
|
|
The Cloudflare extension purges Cloudflare cache when updating pages or re-uploading images, with the primary aim of clearing image cache.
Installation
edit- Download and place the file(s) in a directory called
Cloudflare
in yourextensions/
folder. - Only when installing from Git, run Composer to install PHP dependencies, by issuing
composer install --no-dev
in the extension directory. (See task T173141 for potential complications.) - Add the following code at the bottom of your LocalSettings.php file:
wfLoadExtension( 'Cloudflare' ); $wgCloudflareEmail = ''; $wgCloudflareAPIKey = ''; $wgCloudflareZoneID = '';
- Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.
Usage
editTo use this extension properly, it is necessary to understand and configure the Cloudflare Page Rules (Page Rules Tutorial) · Cloudflare Support docs and $wgUseCdn
settings.
If you do not wish to cache article pages
editPlease set `Cache Level: Bypass` on the path of the article pages.
This is because when $wgUseCdn
is set, article pages start to be cached, and cached pages will be returned to logged-in users as well.
- Cloudflare Page Rules
/wiki/*
Cache Level: Bypass
- LocalSettings.php
$wgCloudflarePurgePage = false;
$wgCloudflarePurgeFile = true;
If you wish to cache article pages (Only available on Business and Enterprise plans.)
editSet `Bypass Cache on Cookie` on the path of the article pages, so that logged-in users will bypass the cache.
- Cloudflare Page Rules
/wiki/*
Cache Level: Cache Everything, Bypass Cache on Cookie:*_session
- LocalSettings.php
$wgCloudflarePurgePage = true;
$wgCloudflarePurgeFile = true;
Configuration parameters
edit- $wgCloudflareEmail
- Email address of your Cloudflare account
- $wgCloudflareAPIKey
- Cloudflare API Key (API Token - Cloudflare → Global API Key)
- $wgCloudflareZoneID
- Cloudflare Zone ID (available in the Overview dashboard)
- $wgCloudflarePurgePage
- false
- $wgCloudflarePurgeFile
- true
Caching Article Pages
editIf enabling $wgCloudflarePurgePage
, it's necessary to set a Page Rule of Bypass Cache on Cookie. (Only available on Business and Enterprise plans.)
See also
edit- Manual:CloudFlare
- MediaWikiでCloudFlareを使う – harugonのブログ - Blog post about this extension
- Extension:CloudflarePurge - Similar extension that doesn't purge files, but doesn't hit the Cloudflare API with every page view, and also purges deleted pages