drupal-caching

Apply cache metadata and invalidate cache bins for Drupal 11 sites.

67|13|Updated Apr 15, 2026
One-click install
npx skills add https://github.com/edutrul/drupal-ai --skill drupal-caching-edutrul
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: drupal-caching
Source: https://github.com/edutrul/drupal-ai/tree/main/.claude/skills/drupal-caching
Command: npx skills add https://github.com/edutrul/drupal-ai --skill drupal-caching-edutrul

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Drupal caching prevents stale content and poor performance by enforcing proper cache metadata and structured cache strategies. Without clear tags, contexts, and max-age, dynamic content may be re-rendered unnecessarily or served stale.

Core Features & Use Cases

  • Cache metadata in render arrays (tags, contexts, max-age) to ensure content invalidates correctly.
  • Manage cache bins and contexts (default, render, data, config) for granular storage and variation.
  • Read/write and invalidate cache using CacheBackendInterface across services to support scalable Drupal apps.

Quick Start

Add render array cache metadata (tags, contexts, max-age) and use CacheBackendInterface to store and invalidate the cached data.

Frequently Asked Questions about drupal-caching

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add cache metadata to Drupal render arrays?

To add cache metadata to Drupal render arrays, you must attach cache tags, contexts, and max-age properties. This ensures dynamic content invalidates correctly and prevents serving stale data across node views or config forms.

What is the difference between cache tags, contexts, and max-age in Drupal?

Cache tags track dependencies for invalidation, cache contexts create variations based on request data like user roles, and max-age defines time-based expiration. Together they form the cache metadata structure required for correct Drupal rendering.

How do I read and write to custom cache bins in Drupal?

You can read and write to custom cache bins in Drupal by using the CacheBackendInterface within your custom services. This allows granular storage and retrieval of cached data across default, render, data, and config bins.

How does tag-based cache invalidation work in Drupal?

Tag-based cache invalidation in Drupal works by associating cache items with specific metadata tags. When underlying content changes, invoking invalidation for those tags automatically clears all cached items marked with them.

Can I use cache contexts to vary user-specific pages in Drupal 11?

Yes, you can use cache contexts to vary user-specific pages in Drupal 11. By applying contexts like user roles or permissions to render arrays, the caching system generates and stores distinct cached versions for each user variation.

Why does my Drupal site serve stale content after updates?

Your Drupal site serves stale content after updates because render arrays lack proper cache metadata. Without defining accurate cache tags for underlying entities, the caching system cannot detect dependencies and fails to invalidate the outdated renders.