drupal-caching

Apply cache tags, contexts, and max-age to Drupal render arrays and blocks.

1|Updated Mar 11, 2026
One-click install
npx skills add https://github.com/proofoftom/drupal-skills --skill drupal-caching
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: drupal-caching
Source: https://github.com/proofoftom/drupal-skills/tree/main/skills/drupal-caching
Command: npx skills add https://github.com/proofoftom/drupal-skills --skill drupal-caching

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill addresses the critical need to manage Drupal's caching mechanisms, preventing stale content and ensuring optimal performance by correctly applying cache metadata.

Core Features & Use Cases

  • Cache Metadata Application: Correctly apply cache tags, contexts, and max-age to render arrays and blocks.
  • Cache Invalidation: Implement strategies for invalidating cached data when underlying content changes.
  • Use Case: When developing a custom block that displays user-specific content, this Skill ensures the block is cached appropriately for different user roles and invalidates when the underlying content is updated.

Quick Start

Apply correct cache metadata (tags, contexts, max-age) to Drupal render arrays and implement cache invalidation patterns.

Frequently Asked Questions about drupal-caching

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

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

Apply cache metadata to Drupal render arrays by defining #cache properties with keys for tags, contexts, and max-age. This ensures cached render arrays and blocks correctly invalidate when underlying dependencies change.

Why does my Drupal block show stale content after updates?

Drupal blocks show stale content when cache invalidation is missing. Implement getCacheTags() and getCacheContexts() on blocks and invalidate cache tags when underlying content updates to prevent stale data.

How does cache bubbling work in Drupal 10 and 11?

Cache bubbling in Drupal 10 and 11 automatically propagates cache metadata from nested render arrays to the top level. This gathered metadata dictates the overall caching behavior, max-age, and invalidation rules for the page.

What's the best way to handle user-specific content caching in Drupal?

Handle user-specific content caching in Drupal by applying cache contexts like user.role to render arrays. This varies block output by user role while maintaining performance through targeted caching.

When do I need to use cache contexts vs cache tags in Drupal?

Use cache contexts in Drupal to vary cached output by request data like user roles, and use cache tags to invalidate cached data when underlying content changes. Both are required for correct cache metadata application.