Drupal is a registered trademark of Dries Buytaert

cache_tags_cdn_optimizer

32 sites No security coverage
View on drupal.org

## INTRODUCTION

The Cache Tags CDN Optimizer module optimizes Drupal's cache invalidation by replacing standard entity cache tags with custom reference tags. This prevents unnecessary cache invalidation when referenced entities are updated, improving performance by only invalidating caches when specific tracked fields change.

The primary use cases for this module are:

- Improve performance by reducing unnecessary cache invalidation for referenced entities
- Selectively invalidate caches only when specific fields of referenced entities change
- Maintain fine-grained control over which cache tags are included in responses
- Provide path-based cache tags to help with managing cached 404 pages

## REQUIREMENTS

This module has no dependencies beyond Drupal core.

## INSTALLATION

Install as you would normally install a contributed Drupal module.
See: https://www.drupal.org/node/895232 for further information.

## CONFIGURATION

1. Navigate to Administration > Configuration > Web services > Cache Tags CDN Optimizer
2. Configure which fields to track for each content type and taxonomy vocabulary:
- Expand the Node or Taxonomy section
- Select a content type or vocabulary
- Check the fields that should trigger cache invalidation when changed
3. Configure additional features:
- **Path Cache Tag**: Enable to add a cache tag for the current path to responses (useful for managing cached 404 pages)
- **Cache Tag Replacement**: Enable for nodes and/or taxonomy terms to replace standard entity cache tags with custom reference tags
- **Blocklist**: Add cache tags to prevent them from being included in responses (supports wildcard matching with * at the end)
- **Debug Mode**: Enable to log detailed information about field changes during entity updates
4. Save the configuration

### Cache Tag Invalidation

The configuration page also provides a utility to manually invalidate specific cache tags:

1. Enter a cache tag (or space-separated list of tags) in the "Cache tag to invalidate" field
2. Click "Invalidate Cache Tag" button
3. The system will confirm the invalidation

## HOW IT WORKS

The module works in several parts:

1. **Response Modification**: When a page is rendered, the module:
- Replaces standard entity cache tags (e.g., `node:123`) with custom reference tags (e.g., `node:reference:123`), except for the entity being directly viewed
- Adds a bundle-specific purge tag (e.g., `node:article:purge_all`) to allow purging all entities of a specific bundle
- Optionally adds a path-based cache tag (e.g., `url/my-page`) to help manage cached pages, especially 404s
- Filters out any cache tags that match the configured blocklist

2. **Selective Invalidation**: When an entity is updated, the module:
- Checks if any of the configured fields have changed
- If they have, invalidates the corresponding custom reference tag
- Optionally logs detailed information about field changes when debug mode is enabled

3. **Entity Deletion**: When an entity is deleted, the module:
- Invalidates both the standard entity cache tag and the custom reference tag

This approach ensures that cached pages containing references to entities are only invalidated when relevant fields of those entities change, not on every entity update.

## TODOs
- Support further entity types?

## MAINTAINERS

Current maintainers:

- dseven GmbH

Activity

Total releases
1
First release
Jul 2025
Latest release
7 months ago
Release cadence
Stability
100% stable

Releases

Version Type Release date
1.0.0 Stable Jul 7, 2025