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(2mo ago)01MITPHPPHP &gt;=8.1

Since Mar 4Pushed 1mo 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 1mo ago

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

36

—

LowBetter than 82% of packages

Maintenance87

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity43

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

67d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/fcb78e176efe130e30227d2488ced5e754634905b05095300f4ffc7dc0df4024?d=identicon)[anthonyc-hastyegg](/maintainers/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

[lizardmedia/module-varnish-warmer

Varnish Cache Warmer Magento2 module by Lizard Media

6276.8k](/packages/lizardmedia-module-varnish-warmer)[mollie/magento2

Mollie Payment Module for Magento 2

1121.6M10](/packages/mollie-magento2)[dotdigital/dotdigital-magento2-extension

Dotdigital for Magento 2

50374.2k18](/packages/dotdigital-dotdigital-magento2-extension)[fredden/magento2-module-javascript-error-reporting

A Magento 2 module which captures JavaScript errors for later review by website administrators

3138.1k](/packages/fredden-magento2-module-javascript-error-reporting)[pagbank/payment-magento

PagBank - Payment for Magento and Adobe

2128.3k7](/packages/pagbank-payment-magento)[redchamps/module-easy-cache-clean

Clean invalidated cache(s) easily in a Magento 2 store

2838.0k](/packages/redchamps-module-easy-cache-clean)

PHPackages © 2026

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