PHPackages                             syrp-nz/silverstripe-cloudlfare-purger - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. syrp-nz/silverstripe-cloudlfare-purger

ActiveSilverstripe-module

syrp-nz/silverstripe-cloudlfare-purger
======================================

Simple Silverstripe plugin to automatically purge pages from CloudFlare on save.

0.1.0(9y ago)41161[1 issues](https://github.com/syrp-nz/silverstripe-cloudflare-purger/issues)MITPHP

Since Sep 5Pushed 9y ago1 watchersCompare

[ Source](https://github.com/syrp-nz/silverstripe-cloudflare-purger)[ Packagist](https://packagist.org/packages/syrp-nz/silverstripe-cloudlfare-purger)[ RSS](/packages/syrp-nz-silverstripe-cloudlfare-purger/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (2)Versions (6)Used By (0)

silverstripe-cloudflare-purger
==============================

[](#silverstripe-cloudflare-purger)

Simple Silverstripe plugin to automatically purge pages from Cloudflare when a Page or a related DataObject is published/saved.

Requirements
------------

[](#requirements)

```
jamesryanbell/cloudflare: ^1.7
silverstripe/cms: ^3.1

```

*NB*: The plugin has been tested against Silverstripe 3.4 but has not been toroughly tested against all versions of Silverstripe 3.x. It should in theory work with all sub-version of Silversrtipe 3. If you come accross an issue using an older version of Silverstripe 3, log an issue or do a PR and I'll look into it.

Installation
------------

[](#installation)

```
composer require syrp-nz/silverstripe-cloudlfare-purger "^0.0"

```

Getting CloudFlare to cache your content
----------------------------------------

[](#getting-cloudflare-to-cache-your-content)

This plugin doesn't automatically configure SilverStripe or CloudFlare to automatically cache your web content.

Before installaing the plugin, you'll need to configure your SilverStripe site to play nice with CloudFlare.

[Configuring CloudFlare to cache SilverStripe pages](https://github.com/syrp-nz/silverstripe-cloudflare-purger/wiki/Configuring-CloudFlare-to-cache-SilverStripe-pages)

Configuration the plugin
------------------------

[](#configuration-the-plugin)

This plugin can be configured via a YML file or via the Site Configuration page. The YML configuration will have precedence over the Site Configuration. You can use a combination of both if you want.

The following configuration options are available:

- `Email` which should be your Cloudflare account's email address.
- `AuthKey` which is your Cloudflare account's AuthKey (can be obtain under *My Settings &gt; API Key*)
- `ZoneIdentifier` which is the numeric identifier of the Zone to which your website domain belongs. There's not really any easy way of retrieving this in Cloudflare without using the API. This will appear as a user friendly drop down in your site configuration page.
- `Paths` which should be an array of absolute paths where your website can be accessed. If your website is only available under one path, you can leave this value blank.
- `HideSiteConfig` is an optional boolean value you can define, if you want to configure all Cloudflare settings in a YML file. Setting this value to `true` will hide the Cloudflare tab from your site configuration.

### Sample YML file

[](#sample-yml-file)

```
CloudflarePurger:
  Email: you@example.com
  AuthKey: yourhexadecimalauthkey
  ZoneIdentifier: yourhexadecimalzoneid
  HideSiteConfig: true
  Paths:
  - "https://example.com/"
  - "http://example.com/"
  - "https://www.example.com/"
  - "http://www.example.com/"
```

### Using the site config

[](#using-the-site-config)

All the parameters can be defined in your site configuration page without the need to edit any YML file.

If some values are defined via the YML file and the `HideSiteConfig` flag is undefined, those values will appear as readonly fields in your Site Configuration.

If your concerned about your `AuthKey` key being visible in the site configuration, make sure to set the `HideSiteConfig` flag to true.

How does the plugin work
------------------------

[](#how-does-the-plugin-work)

The plugin defines a `CloudflarePurgerExtension` DataExtension.This extension can be applied to any DataObject class. It will automatically be applied to the `SiteTree` class.

If the DataObject supports versioning, a call will be made to the Cloudflare API on publication to attempt to purge the the URLs associated to this object. If the DataObject doesn't support versioning, the purge call will occur after each write.

The DataObject can expose a `CloudflarePurgeLinks()` method to specify which URLs should be purged. This method can return either a single URL or array of URLs. The URLs should be relative to the site root.

Otherwise, the `Link()` method will be called on your DataObject.

The plugin also attempts to detect when your site navigation changes. Site navigation changes will cause your entire CloudFlare zone to be purge.

### Applying `CloudflarePurgerExtension` to a DataObject

[](#applying-cloudflarepurgerextension-to-a-dataobject)

If you have a Page type that relies on a child DataObject for its content or if your DataObject is accessible via its own URL, you should implement the `CloudflarePurgerExtension` on it.

You can do so via a YML file.

```
PromoDataObject:
  extensions:
    - CloudflarePurgerExtension
```

Here's how you could customise the URLs that get purged when the `PromoDataObject` gets saved.

```
class PromoDataObject extends DataObject {

    private static $db = [
        'SomeContent' => 'HTMLText'
    ];

    private static $has_one = [
        'Parent' => 'PromoHolderPage'
    ];

    public function Link()
    {
        // This DO can be accessed as a sub-action on the controller of its parent page through its ID.
        // If `CloudflarePurgeLinks` wasn't defined, the individual URL of this DO would be purge, but
        // not its parent.
        return $this->Parent()->Link($this->ID);
    }

    public function CloudflarePurgeLinks()
    {
        // The content of this DO is used when rendering the parent page. So when this DO is saved, we
        // want to purge the parent's page URL as well.
        return [$this->Link(), $this->Parent()->Link()];
    }

}
```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance15

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~11 days

Total

3

Last Release

3515d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6f00d83bd74532798e11cc4ee472c3a6283b731e11d153a271cf66b1209925f0?d=identicon)[webmaster@syrp.co.nz](/maintainers/webmaster@syrp.co.nz)

---

Top Contributors

[![maxime-rainville](https://avatars.githubusercontent.com/u/1168676?v=4)](https://github.com/maxime-rainville "maxime-rainville (2 commits)")

### Embed Badge

![Health badge](/badges/syrp-nz-silverstripe-cloudlfare-purger/health.svg)

```
[![Health](https://phpackages.com/badges/syrp-nz-silverstripe-cloudlfare-purger/health.svg)](https://phpackages.com/packages/syrp-nz-silverstripe-cloudlfare-purger)
```

###  Alternatives

[silvershop/core

Provides an ecommerce product catalog, shopping cart, and order management system

11340.0k42](/packages/silvershop-core)[silverstripe-terraformers/gridfield-rich-filter-header

Rich filter header component for GridField

1325.7k1](/packages/silverstripe-terraformers-gridfield-rich-filter-header)[sunnysideup/ecommerce

Silverstripe E-commerce Application

257.2k79](/packages/sunnysideup-ecommerce)[silverstripe/superglue

102.2k](/packages/silverstripe-superglue)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
