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.
npx skills add tmj-90/gaffer --skill caching-strategygit clone --depth 1 https://github.com/tmj-90/gafferWrote 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.
[](https://agentmods.dev/skills/tmj-90/gaffer/caching-strategy)<a href="https://agentmods.dev/skills/tmj-90/gaffer/caching-strategy"><img src="https://agentmods.dev/badge/skills/tmj-90/gaffer/caching-strategy/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/skills/tmj-90/gaffer/caching-strategy"><img src="https://agentmods.dev/badge/skills/tmj-90/gaffer/caching-strategy.svg" alt="Reviewed on agentmods" width="80" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00095 | $0.01431 |
| Opus 5.5 | $0.00038 | $0.00572 |
| Sonnet 5.5 | $0.00019 | $0.00286 |
| Haiku 4.5 | $0.00010 | $0.00143 |
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 16d 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.
How it starts
The opening of the file, as written. The whole thing — 88 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Add or fix a cache
A cache trades freshness for speed, and every cache goes stale in a specific way. Write the story before the code: key, scope, lifetime, invalidation, the race that can leave a stale value behind, and what happens when the cache is down. A cache without an invalidation plan is a bug on a delay.
Steps
- Prove the need. A measurement showing the same expensive read repeated (the
performance-profilingskill). If the fix is "stop calling it twice", batch the query, or add an index (thesql-query-performanceskill), do that instead. - Choose the innermost layer that solves it. Request-scoped memo (no invalidation
problem); process memory (fast, per instance, diverges across instances); a shared
store such as Redis (consistent across instances, one more dependency); HTTP caching
(RFC 9111:
Cache-Control,ETag/If-None-Match→304, CDN). Callsearch_lorefor the repo's cache helper, key prefixing and serializer; use it. - Design the key. Every input that changes the output is in the key: identifiers,
tenant, the caller's permission scope, locale, query parameters, and a schema or code
version. Missing tenant = data leak; missing version = old shapes after a deploy.
HTTP:
Varyon every request header the response depends on. - Set the TTL from the data. Ask how stale this can be before someone is harmed; that is the TTL. Add ±10–20 % jitter so keys written together do not expire together. TTL is the safety net, not the invalidation plan.
- Invalidate on every write path, after commit. List each code path that changes the source data in a comment beside the cache, and delete (not update) the key after the transaction commits. Deleting before commit lets a reader repopulate the old value. Also close the stale-set race: reader A misses and reads the old row, writer B commits and deletes the key, A then sets the old value, which stays until TTL. Guard with one of: versioned keys (bump a version on write; readers use the current version), a compare-on-set against a version tombstone (the write path replaces the entry with a tombstone carrying the new row version instead of deleting it, and a set succeeds only if its version is ≥ the stored one — a plain delete leaves nothing to compare), lease tokens that a delete invalidates (as in Facebook's memcache), or a short TTL when brief staleness is acceptable and stated.
- Guard against stampedes on expensive keys. On a miss, let one caller recompute
and the rest wait or serve stale: request coalescing / single-flight per key in
process, a short lock key (
SET key NX PX) across processes, probabilistic early refresh (XFetch), orstale-while-revalidate/stale-if-error(RFC 5861) for HTTP. The lock needs a timeout and a fallback so a crashed recomputer does not block reads; an expiring lock is acceptable here only because it guards work, not correctness (a lock that protects a write needs fencing: theconcurrency-and-asyncskill, step 5). - Fail open. A cache timeout or outage falls back to the source with a short client timeout; it is never a user-facing error. Do not cache errors; cache "not found" only deliberately and briefly. Emit hit, miss and eviction counters so the cache's value and a cold or failing store are visible.
- Never share what must not be shared. Authorization decisions, secrets and
per-user data are per-user keys or not cached. Responses that vary by session are
Cache-Control: privateorno-store; a CDN never caches a response carryingSet-Cookieor user data. - Test each behaviour, one test per AC exercising the AC's own behaviour, plus: hit,
miss, invalidation after each listed write path, TTL expiry with a fake clock (no
sleeps), cache-down fallback, two tenants never sharing a value, and for expensive
keys N concurrent misses causing one recomputation (parallel, per the
concurrency-and-asyncskill's step 9). For HTTP, assert the exactCache-Control,ETagandVaryheaders and the304path. - Evidence with the
record-evidenceskill: before/after numbers and test output.
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.
- 16d ago Changed · +24 lines 7d2da798b7c3
- 19d ago First seen · 64 lines · 95 tokens per session scan A 425fbeea16df
caching-strategy is a skill published in the GitHub repository tmj-90/gaffer (2 stars, last pushed 17d ago), licensed Apache-2.0. It adds 95 tokens to every session and 1,431 once invoked, about $0.0004 per session on Opus 5.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-09-28.
Other skills, from other repositories
caching-strategies
Implement effective caching at every layer: in-memory, Redis, CDN, and browser. Activate whenever the user asks about caching, performance optimization for repeated data access, Redis patterns, CDN configuration, cache invalidation, HTTP cache headers, memoization, or stale-while-revalidate strategies.
vector-db
Vector database expert for embeddings, similarity search, RAG patterns, and indexing strategies.
redis-expert
Redis expert for data structures, caching patterns, Lua scripting, and cluster operations.
pinecone
Managed vector DB for production RAG and search.
tanstack-ai-memory-redis
Use when wiring redis() from @tanstack/ai-memory/redis in production — covers client setup (ioredis or node-redis via fromNodeRedis), the storage model, client-side ranking limits, and troubleshooting.
redis-best-practices
Redis development best practices for caching, data structures, and high-performance key-value operations.