drupal-caching

Apply Drupal render array cache metadata with keys, contexts, tags, and max-age.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Drupal rendering pipelines often suffer performance regressions and caching gaps when cache strategies are not consistently applied. This skill defines robust caching practices across render arrays, enabling fast, correct responses by leveraging cache metadata, contexts, tags, and max-age, and by centralizing invalidation logic.

Core Features & Use Cases

  • Apply render array cache metadata (keys, contexts, tags, max-age) to every renderable element.
  • Use CacheableMetadata to merge cache dependencies from multiple sources and apply them to render builds.
  • Manage cache strategies across cache bins and external backends (Redis/Memcached) for scalable sites.
  • Real-world use case: cache a node detail view keyed by node ID and current user context to minimize database loads.

Quick Start

Enable render array caching across pages and implement per-context cache variations to improve throughput.

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 to improve performance?

To apply cache metadata in Drupal, attach #cache properties (keys, contexts, tags, max-age) directly to renderable elements. This ensures proper caching and invalidation for pages, blocks, and dynamic content, minimizing database loads and improving render throughput.

What are Drupal cache contexts and when do I need them for dynamic content?

Drupal cache contexts allow you to cache variations of dynamic content based on user, URL, or language. You need them when content varies by these factors, ensuring accurate personalized responses while maintaining high caching performance across different site contexts.

Does this caching approach work with Redis or Memcached backends for Drupal 10/11?

Yes, this caching approach supports Drupal 10/11 sites using Redis or Memcached backends. It manages cache strategies across bins and external backends, enabling scalable performance for high-traffic sites with robust cache invalidation logic.

What's the best way to merge cache dependencies from multiple sources in Drupal?

The best way to merge cache dependencies in Drupal is using CacheableMetadata to combine cache tags, contexts, and max-age from multiple sources. This centralizes invalidation logic and applies unified cache strategies across complex render builds.

Why does my Drupal node detail view keep hitting the database instead of serving cached content?

Your Drupal node view likely lacks proper cache metadata. Apply #cache keys based on node ID and current user context to enable caching. Without these cache tags and contexts, Drupal cannot identify cached variations and must rebuild the page repeatedly.