Extension:Cloudflare

MediaWiki extensions manual
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
README
  • $wgCloudflareEmail
  • $wgCloudflareAPIKey
  • $wgCloudflareZoneID
  • $wgCloudflarePurgePage
  • $wgCloudflarePurgeFile

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 your extensions/ 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

edit

To 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

edit

Please 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.)

edit

Set `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

edit

If 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