Drupal is a registered trademark of Dries Buytaert
Release: Leaflet 10.4.11 Minor update available for module leaflet (10.4.11). Release: Session Inspector 1.0.8 Minor update available for module session_inspector (1.0.8). Release: Migrate QA 2.0.4 Minor update available for module migrate_qa (2.0.4). Release: CKEditor Description List 3.0.0 Major update available for module ckeditor_descriptionlist (3.0.0). Release: FlowDrop 2.4.0 Minor update available for module flowdrop (2.4.0). Release: JWT Token Refresh 1.0.4 Minor update available for module jwt_token_refresh (1.0.4). Release: ConReg 1.0.0-beta1 First beta version released for module conreg (1.0.0-beta1). Release: AI Image Studio 1.0.0-beta8 New beta version released for module ai_image_studio (1.0.0-beta8). Usage Milestone: Role Theme Switcher Module role_theme_switcher crossed 1,000 active installs. Module Revived: Decoupled Router 2.0.7 Module decoupled_router updated after 11 months of inactivity (2.0.7).

This module integrates with the Purge module to invalidate Cloudflare CDN caches. It adds a 'Cache-Tag' header to Drupal responses, allowing Cloudflare to track and purge content based on Drupal's cache tags using the Cloudflare API.

This module adds Cloudflare CDN cache invalidation support by integrating with the Purge module.

Features

Integrates with the Purge module to do the following:

  • Adds a "Cache-Tag" HTTP response header to all of Drupal's cacheable responses. The value of the header is a hashed list of all the Drupal cache tags for that response. Cloudflare stores these cache tags along with the cache data for later lookup.
  • Uses the Cloudflare API to send a purge-by-tags request to Cloudflare when Drupal invalidates one or more cache tags.

Post-Installation

Dealing with hosting environment response header limitations

This module adds a "Cache-Tag" HTTP response header which may be very large on pages with many cache tags. Some web servers have strict limits on the size of HTTP response headers. Exceeding this limit can cause errors.

To protect from this scenario, this module exposes a container parameter, cloudflare_purger.max_response_header_length. If the Cache-Tag header for a response exceeds this value, the header is not set and the entire response is marked uncacheable by the Cloudflare CDN using the Cloudflare-CDN-Cache-Control header. (Note - other caching layers may continue to cache the response!). Marking it uncacheable in Cloudflare is critical to prevent the page from being cached indefinitely as it won't have any of the cache tag metadata needed to support invalidations.

Example customization

Cloudflare supports individual response header sizes up to 16kB, but the Acquia hosting environment only supports header sizes of 8kB. In order to safely use this module with Acquia hosting, use this configuration in your services.yml file:

  parameters:
    # 8192 - strlen("Cache-Tag: ") = 8181
    cloudflare_purger.max_response_header_length: 8181

This ensures that the the Cache Tag header size remains compliant with both Acquia's origin servers and Cloudflare.

Preventing hash collisions if environments share a common zone

If multiple environments (dev / test / prod, for example) share a common Cloudflare zone and also share a common hash_salt setting, that would risk cross-environment cache purging. For such configurations this module supports a setting, cloudflare_purger_cache_tag_prefix, which can be used to override the cache tag prefix that is used to help ensure uniqueness of cache tags. By using this setting, each environment (dev / test / prod) can have its own unique cache tag prefix set, thus ensuring that cache purges do not break environment isolation.

Example custom prefixes (Acquia Hosting)

Say there are three environments: dev, test, and prod. There is also an environment variable that denotes which environment is which. By adding this to settings.php, each would have its own unique prefix.

  if (isset($_ENV['AH_SITE_GROUP'], $_ENV['AH_SITE_ENVIRONMENT'])) {
    $settings['cloudflare_purger_cache_tag_prefix'] = $_ENV['AH_SITE_GROUP'] . '.' . $_ENV['AH_SITE_ENVIRONMENT'];
  }

API Token Best Practices

As a general rule, limit the token permissions to only include the bare minimum. In the case of this module, only the Purge permission for a particular Zone is required.

Hosts with fixed outbound IP addresses

To further harden the token, always include the outbound IP address(es) of the origin server(s) in the Client IP Address Filtering section. This option will ensure that only the origin server(s) are able to use the token, so even in the event of a token compromise, it cannot be used by bad actors.

Additional Requirements

The Purge and Key modules are required.

Similar projects

The Cloudflare module has a cloudflare_purge sub-module, however this is not compatible with Cloudflare's header and account limits in 2026 and duplicates some functionality from the purger module.

Cloudflare purge is a completely standalone implementation that does not integrate with the Purge module.

Supporting this Module

To come...

Activity

Tracked releases
5
Tracked since
Jul 2026
Latest release
4 days ago
Releases (12 mo)
5 ▲ from 0
Maintenance
Active

Release Timeline

Releases

Version Type Release date
1.0.0 Stable Aug 19, 2026
1.0.0-beta3 Pre-release Aug 6, 2026
1.0.0-beta2 Pre-release Jul 28, 2026
1.0.0-beta1 Pre-release Jul 13, 2026
1.0.x-dev Dev Jul 2, 2026