pn-caching

pn-caching is a skill for Cursor from perniemann/pnCore. It costs 58 tokens per session (1,590 once invoked), scanned A, original, MIT.

A guide to caching data in browsers, CDNs, applications, Redis, Next.js, SWR, or React Query so repeated requests can reuse recent results.

In plain words
What is it for?
Use it when adding Redis or in-memory caching, HTTP cache headers, CDN caching, or client-side data fetching caches.
Why use it?
It reduces database and external-service work and can make responses faster, while addressing expiration and keeping cached data reasonably current.

Skill for Cursor

Written for Cursor: shipped in a Cursor plugin.

Part of the pn-core plugin — 133 skills, 19 commands, 9 agents, 1 MCP server shipped together

Good fit Use it when adding Redis or in-memory caching, HTTP cache headers, CDN caching, or client-side data fetching caches.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/perniemann/pncore/pn-caching
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.

Any agent
npx skills add perniemann/pnCore --skill pn-caching
Clone the repo
git clone --depth 1 https://github.com/perniemann/pnCore

Made for: Cursor.

Or install pn-core, the plugin that ships this one along with the rest of its 133 skills, 19 commands, 9 agents, 1 MCP server.

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 pn-caching

README.md
[![agentmods](https://agentmods.dev/badge/skills/perniemann/pncore/pn-caching/github.svg)](https://agentmods.dev/skills/perniemann/pncore/pn-caching)
Your own site
<a href="https://agentmods.dev/skills/perniemann/pncore/pn-caching"><img src="https://agentmods.dev/badge/skills/perniemann/pncore/pn-caching/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.

agentmods 80×15 button for pn-caching

Your own site · 80×15
<a href="https://agentmods.dev/skills/perniemann/pncore/pn-caching"><img src="https://agentmods.dev/badge/skills/perniemann/pncore/pn-caching.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 58 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,590 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. A grade says what 26 rules found in the file — not that it is safe.
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.00058 $0.01590
Opus 5 $0.00029 $0.00795
Sonnet 5 $0.00012 $0.00318
Haiku 4.5 $0.00006 $0.00159

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

Security

Grade A, and why

pn-caching scanned grade A with 1 finding 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.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

const fetcher = (url: string) => fetch(url).then((r) => r.json());
packages/pn-core-mcp/content/skills/backend/pn-caching/SKILL.md · 212 lines

How it starts

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

Caching

When to use

  • Reducing database query load or external API call volume
  • Adding in-memory or Redis caching to a backend service
  • Configuring HTTP cache headers and CDN behaviour
  • Using Next.js server-side caching (fetch options, unstable_cache, route segment config)
  • Adding SWR or React Query for client-side data fetching with stale-while-revalidate

Cache hierarchy

Browser Cache (memory / disk)
    ↓ miss
CDN / Edge Cache (Vercel Edge, Cloudflare)
    ↓ miss
Application Cache (Redis / in-memory)
    ↓ miss
Database / External API

Redis patterns

Read-through (most common)

import { Redis } from "ioredis";

const redis = new Redis(process.env.REDIS_URL!);

async function getProduct(id: string): Promise<Product> {
  const cached = await redis.get(`product:${id}`);
  if (cached) return JSON.parse(cached) as Product;

  const product = await db.product.findUniqueOrThrow({ where: { id } });
  await redis.setex(`product:${id}`, 300, JSON.stringify(product)); // TTL: 5 min
  return product;
}

Write-through (keep cache consistent on writes)

async function updateProduct(id: string, data: Partial<Product>): Promise<Product> {
  const product = await db.product.update({ where: { id }, data });
  await redis.setex(`product:${id}`, 300, JSON.stringify(product));
  return product;
}

Cache invalidation on write

async function deleteProduct(id: string): Promise<void> {
  await db.product.delete({ where: { id } });
  await redis.del(`product:${id}`);
  await redis.del("products:list"); // invalidate list caches too
}

Stampede protection (dogpile prevention)

async function getWithLock<T>(key: string, ttl: number, fetcher: () => Promise<T>): Promise<T> {
  const cached = await redis.get(key);
  if (cached) return JSON.parse(cached) as T;

  const lockKey = `lock:${key}`;
  const acquired = await redis.set(lockKey, "1", "NX", "EX", 5); // 5s lock
  if (!acquired) {
    await new Promise((r) => setTimeout(r, 100));
    return getWithLock(key, ttl, fetcher); // retry after brief wait
  }
  try {
    const value = await fetcher();
    await redis.setex(key, ttl, JSON.stringify(value));
    return value;
  } finally {
    await redis.del(lockKey);
  }
}

Read the full file on GitHub · 212 lines

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 · 212 lines · 58 tokens per session scan A 56f7175d2149

Subscribe to this mod's changes

pn-caching is a skill published in the GitHub repository perniemann/pnCore (0 stars, last pushed 2d ago), licensed MIT. It adds 58 tokens to every session and 1,590 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.