abderrahimghazali/drupal-boost/caching-strategy
Claude Code and agent skill by abderrahimghazali/drupal-boost
- community
Checking that the SKILL.md file is still in the repository.
Drupal cache API patterns including cache tags, cache contexts, max-age, render caching, and cache invalidation strategies. Use when implementing caching, debugging cache issues, or optimizing Drupal performance.
Install
npx vskill@latest install abderrahimghazali/drupal-boost/caching-strategySKILL.md
The same SKILL.md was published earlier as abderrahimghazali/drupal-boost/caching-strategy.
Drupal Caching Strategy
Cache Metadata (The Three Pillars)
Every render array MUST include cache metadata:
Cache Tags — "What invalidates this cache?"
node:NID— Invalidated when a specific node changesnode_list— Invalidated when any node is created/updated/deleteduser:UID— Invalidated when a specific user changestaxonomy_term:TID— Invalidated when a term changesconfig:system.site— Invalidated when site config changes- Custom:
MODULE_NAME:ENTITY:ID
Invalidate manually:
Cache Contexts — "What makes this vary?"
user— Different per useruser.permissions— Different per permission set (fewer variations)user.roles— Different per role combinationurl.path— Different per URL pathurl.query_args— Different per query stringurl.query_args:sort— Different per specific query paramlanguages:language_interface— Different per languagetheme— Different per themeroute— Different per route
Max-Age
Cache::PERMANENT(or-1) — Never expires (invalidated by tags only)0— Uncacheable (use sparingly — kills performance)3600— Cache for 1 hour86400— Cache for 1 day
Cache Bubbling
Cache metadata "bubbles up" from child elements to parents. Drupal automatically merges:
- Tags: Union of all tags
- Contexts: Union of all contexts
- Max-age: Minimum of all max-ages (most restrictive wins)
This means if ANY child has max-age: 0, the entire page becomes uncacheable.
Lazy Builders
For uncacheable content within cacheable pages:
The lazy builder method:
BigPipe streams these placeholders after the main page loads.
Custom Cache Bins
For storing computed data:
Usage:
Performance Anti-Patterns
max-age: 0on render arrays that could be cached- Missing cache tags (content changes but cache is stale)
- Missing cache contexts (same content shown to all users when it should vary)
\Drupal::cache()->deleteAll()instead of tag-based invalidation- Not using lazy builders for dynamic content in static pages
drupal_flush_all_caches()in code (usedrush crin dev only)
Debugging Cache
Enable debug headers in development.services.yml:
Then check response headers: X-Drupal-Cache-Tags, X-Drupal-Cache-Contexts, X-Drupal-Cache-Max-Age.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/caching-strategy/SKILL.md
Popularity
- 7-day trend score
- 5
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/abderrahimghazali/drupal-boost/caching-strategy)