caching-strategy

caching-strategy is a skill for Claude Code from abderrahimghazali/drupal-boost. It costs 42 tokens per session (1,003 once invoked), scanned A, original, MIT.

A collection of Drupal caching patterns for storing rendered content and deciding when cached results should differ or be cleared. Drupal is a content-management system used to build websites.

In plain words
What is it for?
Use it when adding render caching, choosing cache tags and contexts, setting cache lifetimes, invalidating caches, or investigating Drupal cache problems.
Why use it?
It helps prevent stale content and incorrect results being shown to users while avoiding unnecessary work on each request.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter.

Part of the drupal-boost plugin — 13 skills, 8 commands, 6 agents, 3 hooks shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/abderrahimghazali/drupal-boost/caching-strategy
Any agent
npx skills add abderrahimghazali/drupal-boost --skill caching-strategy
Clone the repo
git clone --depth 1 https://github.com/abderrahimghazali/drupal-boost

Made for: Claude Code.

Or install drupal-boost, the plugin that ships this one along with the rest of its 13 skills, 8 commands, 6 agents, 3 hooks.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for caching-strategy

README.md
[![agentmods](https://agentmods.dev/badge/skills/abderrahimghazali/drupal-boost/caching-strategy.svg)](https://agentmods.dev/skills/abderrahimghazali/drupal-boost/caching-strategy)
Your own site
<a href="https://agentmods.dev/skills/abderrahimghazali/drupal-boost/caching-strategy"><img src="https://agentmods.dev/badge/skills/abderrahimghazali/drupal-boost/caching-strategy.svg" alt="Measured on agentmods" height="20"></a>
Per session 42 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,003 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00042 $0.01003
Opus 5 $0.00021 $0.00502
Sonnet 5 $0.00008 $0.00201
Haiku 4.5 $0.00004 $0.00100

Measured 5d ago against content hash 0d4ac4cbe83f, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

caching-strategy scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/caching-strategy/SKILL.md · 140 lines

How it starts

The opening of the file, as written. The whole thing — 140 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Drupal Caching Strategy

Cache Metadata (The Three Pillars)

Every render array MUST include cache metadata:

$build = [
  '#theme' => 'my_template',
  '#data' => $data,
  '#cache' => [
    'tags' => ['node_list', 'node:42'],           // WHAT invalidates this
    'contexts' => ['user.permissions', 'url.path'], // WHAT varies this
    'max-age' => 3600,                              // HOW LONG to cache (seconds)
  ],
];

Cache Tags — "What invalidates this cache?"

  • node:NID — Invalidated when a specific node changes
  • node_list — Invalidated when any node is created/updated/deleted
  • user:UID — Invalidated when a specific user changes
  • taxonomy_term:TID — Invalidated when a term changes
  • config:system.site — Invalidated when site config changes
  • Custom: MODULE_NAME:ENTITY:ID

Invalidate manually:

\Drupal\Core\Cache\Cache::invalidateTags(['node:42']);

Cache Contexts — "What makes this vary?"

  • user — Different per user
  • user.permissions — Different per permission set (fewer variations)
  • user.roles — Different per role combination
  • url.path — Different per URL path
  • url.query_args — Different per query string
  • url.query_args:sort — Different per specific query param
  • languages:language_interface — Different per language
  • theme — Different per theme
  • route — 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 hour
  • 86400 — 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:

$build['dynamic_part'] = [
  '#lazy_builder' => ['MODULE_NAME.my_service:renderDynamic', [$entity_id]],
  '#create_placeholder' => TRUE,
];

Read the full file on GitHub · 140 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago First seen · 140 lines · 42 tokens per session scan A 0d4ac4cbe83f

Subscribe to this mod's changes

caching-strategy is a skill published in the GitHub repository abderrahimghazali/drupal-boost (1 stars, last pushed 5mo ago), licensed MIT. It adds 42 tokens to every session and 1,003 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.