Extension:Cloudflare

Category:Extensions without a compatibility policyCategory:MIT licensed extensions
MediaWiki extensions manual
Cloudflare
Release status: betaCategory:Beta status extensions
Implementation other (invalid type)Category:Extensions with invalid or missing type
Description Purge Cache for CloudFlare.
Author(s) Harugon1talk
Latest version 0.1.3
MediaWiki >= 1.35Category:Extensions with manual MediaWiki version
PHP 7.4+
Database changes No
Composer harugon/cloudflareCategory:Extensions supporting Composer
License MIT License
Download Category:Extensions in GitHub version control
README
  • $wgCloudflareEmail
  • $wgCloudflareAPIKey
  • $wgCloudflareZoneID
  • $wgCloudflarePurgePage
  • $wgCloudflarePurgeFile
Category:All extensions

The Cloudflare extension purges Cloudflare cache when updating pages or re-uploading images, with the primary aim of clearing image cache.


Installation

  • 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 T173141 for potential complications.)Category:Extensions requiring Composer with git
  • Add the following code at the bottom of your LocalSettings.php file:
    wfLoadExtension( 'Cloudflare' );
    $wgCloudflareEmail = '';
    $wgCloudflareAPIKey = '';
    $wgCloudflareZoneID = '';
    
  • Yes Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

Usage

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

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

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

$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

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

Category:All extensions Category:Beta status extensions Category:Extensions in GitHub version control Category:Extensions requiring Composer with git Category:Extensions supporting Composer Category:Extensions with invalid or missing type Category:Extensions with manual MediaWiki version Category:Extensions without a compatibility policy Category:LocalFilePurgeThumbnails extensions Category:MIT licensed extensions Category:PageDeleteComplete extensions Category:PageMoveComplete extensions Category:PageSaveComplete extensions