PHPackages                             hastyegg/module-cloudflare - 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. [Caching](/categories/caching)
4. /
5. hastyegg/module-cloudflare

ActiveMagento2-module[Caching](/categories/caching)

hastyegg/module-cloudflare
==========================

Magento 2 module — automatically purge Cloudflare cache on Magento cache flush

v1.0.0(4mo ago)05MITPHPPHP &gt;=8.1

Since Mar 4Pushed 3mo agoCompare

[ Source](https://github.com/hastyegg/magento2-module-cloudflare)[ Packagist](https://packagist.org/packages/hastyegg/module-cloudflare)[ RSS](/packages/hastyegg-module-cloudflare/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (3)Versions (3)Used By (0)

hastyegg-magento-cloudflare
===========================

[](#hastyegg-magento-cloudflare)

**Keep your storefront in sync — automatically.**

When you manage a Magento store behind Cloudflare, cached pages can serve stale content after product updates, price changes, or CMS edits. This module eliminates that gap by automatically purging your entire Cloudflare cache every time Magento's cache is flushed — whether from the Admin Panel or the command line.

Why This Matters
----------------

[](#why-this-matters)

- **No more stale pages.** Customers always see the latest prices, inventory, and content.
- **Zero manual steps.** Your team doesn't need to log into Cloudflare to purge after every change.
- **Instant verification.** Credentials are validated on save so you know the connection works before anything goes live.
- **No performance impact.** The module only fires during cache flush events — it adds nothing to page load or checkout.

Features
--------

[](#features)

FeatureDescription**Automatic Purge**Triggers a Cloudflare "Purge Everything" on any Magento cache flush**Connection Verification**Tests your API credentials when you hit Save Config and shows a success or error message**Encrypted Storage**API tokens are stored using Magento's native encryption — never in plain text**Admin Configuration**Simple setup under Stores → Configuration with no code changes required**Logging**All purge attempts (success and failure) are logged to `var/log/system.log`Compatibility
-------------

[](#compatibility)

- Magento 2.4.x (Open Source &amp; Commerce)
- PHP 8.1+
- Cloudflare Free, Pro, Business, or Enterprise plan

---

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

[](#installation)

```
composer require hastyegg/module-cloudflare
bin/magento setup:upgrade
bin/magento setup:di:compile
bin/magento setup:static-content:deploy -f
bin/magento cache:flush
```

Configuration
-------------

[](#configuration)

1. Log in to the **Magento Admin Panel**
2. Navigate to **Stores → Configuration → General → Cloudflare**
3. Fill in the settings:

SettingWhere to Find It**Enable**Set to *Yes* to activate**Zone ID**Cloudflare Dashboard → your domain → **Overview** (right sidebar)**API Token**Cloudflare Dashboard → **My Profile → API Tokens → Create Token**4. Click **Save Config**
5. A green success message confirms the connection: *"Connected to Cloudflare zone example.com successfully."*

### Creating a Cloudflare API Token

[](#creating-a-cloudflare-api-token)

1. Go to [Cloudflare API Tokens](https://dash.cloudflare.com/profile/api-tokens)
2. Click **Create Token**
3. Use the **Custom Token** template
4. Set permissions to: **Zone → Cache Purge → Purge**
5. Under Zone Resources, select your specific domain
6. Click **Continue to Summary → Create Token**
7. Copy the token into the Magento configuration

Cache Events
------------

[](#cache-events)

The module listens to the following Magento events:

EventTrigger`adminhtml_cache_flush_all`Admin → System → Cache Management → Flush Magento Cache`adminhtml_cache_flush_system`Admin → System → Cache Management → Flush Cache Storage`clean_cache_by_tags`Programmatic cache clean by tagsModule Structure
----------------

[](#module-structure)

```
app/code/HastyEgg/Cloudflare/
├── Model/
│   └── CachePurger.php              # Cloudflare API client (purge & verify)
├── Observer/
│   ├── PurgeCloudflareCache.php     # Listens for cache flush events
│   └── VerifyCloudflareCredentials.php  # Validates credentials on config save
├── etc/
│   ├── acl.xml                      # Admin permissions
│   ├── adminhtml/
│   │   ├── events.xml               # Config save verification event
│   │   └── system.xml               # Admin configuration fields
│   ├── config.xml                   # Default configuration values
│   ├── events.xml                   # Cache flush event observers
│   └── module.xml                   # Module declaration
└── registration.php                 # Module registration

```

Troubleshooting
---------------

[](#troubleshooting)

ProblemSolution"Zone ID or API Token is missing" warningEnsure both fields are filled in and saved"Cloudflare API error: Invalid API Token"Regenerate the token in Cloudflare with **Zone.Cache Purge** permissionPurge not firingConfirm **Enable** is set to *Yes* and check `var/log/system.log` for details403 from Cloudflare APIThe token may not have permission for the specified Zone ID

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance78

Regular maintenance activity

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity44

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

Unknown

Total

1

Last Release

121d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/83484093?v=4)[anthonyc-hastyegg](/maintainers/anthonyc-hastyegg)[@anthonyc-hastyegg](https://github.com/anthonyc-hastyegg)

---

Top Contributors

[![anthonyc-hastyegg](https://avatars.githubusercontent.com/u/83484093?v=4)](https://github.com/anthonyc-hastyegg "anthonyc-hastyegg (1 commits)")

### Embed Badge

![Health badge](/badges/hastyegg-module-cloudflare/health.svg)

```
[![Health](https://phpackages.com/badges/hastyegg-module-cloudflare/health.svg)](https://phpackages.com/packages/hastyegg-module-cloudflare)
```

###  Alternatives

[mollie/magento2

Mollie Payment Module for Magento 2

1131.9M16](/packages/mollie-magento2)[loki/magento2-components

Core module for defining Alpine.js components with advanced AJAX features

1011.8k26](/packages/loki-magento2-components)[fastly/magento2

Fastly CDN Module for Magento 2.4.x

1564.4M1](/packages/fastly-magento2)[run-as-root/magento2-prometheus-exporter

Magento2 Prometheus Exporter

68357.9k](/packages/run-as-root-magento2-prometheus-exporter)[buckaroo/magento2

Buckaroo Magento 2 extension

32420.3k8](/packages/buckaroo-magento2)[lizardmedia/module-varnish-warmer

Varnish Cache Warmer Magento2 module by Lizard Media

6180.3k](/packages/lizardmedia-module-varnish-warmer)

PHPackages © 2026

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