Cross-session WebFetch cache for Claude Code. SQLite, 7-day TTL, MCP plugin.
Copy the AI prompt to install this server into Claude Code, Cursor, or another agent β or use 1-click editor setup below.
π‘ Paste the JSON block into your client's configuration file under mcpServers, then restart the application.
Persistent cross-session WebFetch cache for Claude Code. Cached reads in ~0.07ms β orders of magnitude faster than re-fetching.
Claude Code's built-in cache lasts 15 minutes, within one session. Every new session re-fetches from scratch. claude-webcache persists results across sessions in a local SQLite database β instant cache hits, zero network cost.
v0.1.5+: every WebFetch is automatically saved via PostToolUse hook β nothing to configure.

Works in: Claude Code CLI Β· Desktop (Mac/Windows) Β· VS Code extension Β· JetBrains plugin β same command everywhere.
Done. Every WebFetch is auto-cached from now on.
Optionally add the usage pattern to ~/.claude/CLAUDE.md to also check the cache before fetching (saves the WebFetch call entirely on repeat URLs).
Plugin TUI not working? There's an open Claude Code bug (#41653) where
/plugin installrejects third-party sources with "source type not supported." Use the CLI command above β it bypasses the TUI and works fine.Fallback (no marketplace):
Requires Node.js 22.5+ (uses built-in node:sqlite β no native deps, no install step).
Then register in ~/.claude/settings.json (replace path with output of npm root -g):
See CONTRIBUTING.md.
v0.1.5+ auto-caches every WebFetch automatically. The pattern below is optional: add it to ~/.claude/CLAUDE.md to also check the cache before making a WebFetch β this saves the WebFetch call entirely on repeat URLs.
Auto-read (v0.5+): nothing to do. A PreToolUse hook checks the cache before every WebFetch/WebSearch. On a hit it serves the cached copy and skips the network; on a miss the call runs normally and the PostToolUse hook stores the result. Same URL + same prompt (or same search query) in any future session = instant hit, zero network cost.
Manual lookup is still available if you want it: call cached_fetch(url, prompt) (or cached_search(query)) β returns the cached text, or [CACHE_MISS] β¦ if absent. Disable auto-read with WEBCACHE_AUTOREAD=0.
The cache stores the URL alongside the response in ~/.webcache/cache.db. By default, claude-webcache strips obvious credentials from the stored URL before write (user:pass@host and query params named token, api_key, apikey, access_token, auth, secret, password, key, signature, etc.).
That's display-level redaction, not key-level. The cache key still hashes the original URL, so re-fetching the same authenticated URL hits the cache. If you want a stricter trade-off:
With WEBCACHE_STRICT_REDACT=1, the cache key is computed from the redacted URL too β endpoints differing only in ?token=A vs ?token=B collide in one slot. Safe for pass-through auth (identical content), unsafe for personalized endpoints (different users see each other's cached data).
Bottom line: prefer header-based auth (Authorization: headers) over URL-embedded tokens. Don't commit ~/.webcache/cache.db to git.
Multiple projects sharing one machine? Isolate per-project caches:
Default namespace is the empty string "" (shared cache for v0.3 behavior). Inspect/manage per-namespace via CLI: claude-webcache namespaces, claude-webcache --namespace gosdelo stats.
| Tool | Args | Returns |
|---|---|---|
cached_fetch | url, prompt | cached text, or [CACHE_MISS] <url> |
cached_search | query | cached WebSearch results, or [CACHE_MISS] <query> (websearch namespace, short TTL) |
cache_store | url, prompt, output | stored |
cache_stats | global? | { namespace, total, hits, misses, hit_rate, last, db_size_bytes, evicted, oversize_skipped, last_hook_error_at, top_urls, ... } |
cache_list | limit?, offset?, global? | recent URLs (most recent first) |
cache_invalidate | url | { deleted: N } β drops every entry for that URL in current namespace |
cache_clear | older_than_days?, confirm? | { deleted: N } β partial wipe by age, or full wipe with confirm:"YES" |
cache_warm | entries: [{url,prompt}] or urls[]+prompt | { hits, misses, invalid } β bulk pre-flight in one call |
cache_refresh | url, prompt | [CACHE_MISS] <url> β invalidates and signals re-fetch |
The npm package ships a claude-webcache binary for ad-hoc inspection and a local web dashboard:
The dashboard renders top URLs by hits, top domains (with avg hits / last fetch / entry counts), full search-able paginated list with one-click invalidate + refresh buttons. Pure stdlib β no extra deps to install.
| Variable | Default | Effect |
|---|---|---|
WEBCACHE_TTL_DAYS | unlimited | Global TTL in days. 0 or unset = unlimited. |
WEBCACHE_MAX_SIZE_MB | unlimited | Above this size, LRU eviction drops ~20% of oldest-by-last_hit_at entries on next write (debounced every 100 writes). |
WEBCACHE_DOMAIN_TTL | none | Per-domain TTL JSON: {"news.com":1,"reuters.com":1,"arxiv.org":0}. Days; 0 = unlimited. Suffix-matches subdomains. Overrides global TTL when matched. |
WEBCACHE_NAMESPACE | "" (shared) | Isolate the cache per project. Different namespaces never see each other's entries. |
WEBCACHE_MAX_OUTPUT_MB | 10 | Reject WebFetch responses larger than N MB. Stats track oversize_skipped counter and last_oversize_url. |
WEBCACHE_COMPRESS | off | 1 enables gzip on responses β₯4 KB. Stored as base64 in TEXT column. Existing uncompressed rows read fine (BC). |
WEBCACHE_STRICT_REDACT | off | 1 makes the cache key use the redacted URL β collides per endpoint regardless of token value. See Security above. |
WEBCACHE_QUIET | off | 1 suppresses hook stderr output (file log at ~/.webcache/hook.log still written). |
WEBCACHE_DEBUG | off | 1 enables verbose tracing in the auto-cache hook. |
WEBCACHE_SEARCH_TTL_HOURS | 6 | TTL for cached WebSearch results (the websearch namespace). Search rankings drift, so this is short by default. 0 = never expire. |
WEBCACHE_AUTOREAD | on | 0 disables the PreToolUse auto-read hooks (cache still fills via PostToolUse; you read it manually via cached_fetch/cached_search). |
Every new session injects a one-liner so Claude knows the cache exists:
No output if cache is empty. [ns=...] is omitted when using the default namespace.
SQLite at ~/.webcache/cache.db (WAL mode, synchronous=NORMAL, busy_timeout=5000).
Cache key = SHA256(namespace + "|" + canonical(url) + "|" + prompt). Default TTL: unlimited (set WEBCACHE_TTL_DAYS=N for N-day expiry).
No reviews yet β be the first to share how this listing worked for you.
Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.
[](https://allmcps.com/mcp/claude-webcache)<a href="https://allmcps.com/mcp/claude-webcache"><img src="https://allmcps.com/api/badge/claude-webcache?style=directory" alt="Claude Webcache on AllMCPs" /></a>