← Blog

Claude skill Cache-Control misconfiguration in SPA and API responses — SA-SKL-CACHING3

Cache headers are the contract between your MCP skill's server and every caching layer between it and the browser — Caddy's response cache, CDN edge nodes, and the browser itself. When that contract has four recurring mistakes — serving the SPA entry point with an immutable TTL, using Expires: 0 which CDNs ignore in favor of their default TTL, letting Surrogate-Control reach the browser, and using stale-while-revalidate without stale-if-error — the result is either sensitive data served from CDN cache to wrong users, or unnecessary 5xx errors to legitimate users during revalidation failures.

By SkillAudit  |  8 Nov 2026

Cache headers in MCP skill deployments

An MCP skill typically has three classes of responses with different caching requirements: the SPA bundle entry point (index.html) which must never be cached with a long TTL; hashed static assets (main.a1b2c3.js, style.d4e5f6.css) which can be cached indefinitely because the hash changes with the content; and API responses which must distinguish between private authenticated data (never cache) and public read-heavy data (cache with appropriate TTL and variation keys). Getting the boundary between these classes wrong has two impact types: availability degradation (users get stale app after deploy, errors during revalidation) and security degradation (private data served from CDN to wrong users).

SA-SKL-CACHING3 findings at a glance
HIGHCACHING3-001 — SPA index.html served with Cache-Control: max-age=31536000 or immutable; users locked to stale app bundle reference until cache expires or hard refresh
HIGHCACHING3-002 — API response with Expires: 0 or past date; CDN ignores Expires: 0 and caches under its default TTL (typically 1 hour); private data served from cache
MEDIUMCACHING3-003 — Surrogate-Control: max-age=3600 not stripped by CDN; browser receives CDN TTL and caches for 1 hour instead of intended no-cache
MEDIUMCACHING3-004 — Cache-Control: stale-while-revalidate=300 without stale-if-error; revalidation failure under load causes immediate 5xx to users instead of serving stale content

CACHING3-001 — SPA index.html cached with long max-age

The correct caching strategy for a Single Page Application separates the entry point from the asset bundle. Hashed asset files (main.a1b2c3d4.js) can safely use Cache-Control: public, max-age=31536000, immutable because the hash is baked into the filename — when the content changes, the filename changes, and the cache is never stale. The index.html entry point, however, contains references to the current hashed filenames. If index.html is cached with a long TTL, users receive a stale index.html after a deploy, which references old asset hashes that no longer exist on the CDN — causing the app to fail to load until the user clears their cache or the entry point TTL expires.

The index.html must use Cache-Control: no-cache (which requires a revalidation on every request but allows serving from cache if the ETag matches) or Cache-Control: no-store (which always fetches fresh). no-cache is preferred for index.html because it uses conditional GET requests that return 304 Not Modified without retransmitting the body when the file hasn't changed.

# VULNERABLE Caddyfile — same long max-age for index.html and hashed assets
skillaudit.dev {
    root * /srv/app
    file_server

    # VULNERABLE: applies 1-year TTL to ALL files including index.html
    # After deploy, users get stale index.html referencing old hashed assets
    header Cache-Control "public, max-age=31536000, immutable"
}
# FIXED Caddyfile — no-cache for index.html, immutable for hashed assets
skillaudit.dev {
    root * /srv/app
    file_server

    # index.html: no-cache (revalidate on every request via ETag; serves from cache if 304)
    @entry_point {
        path /index.html /
        path_regexp \.html$
    }
    header @entry_point Cache-Control "no-cache"
    header @entry_point X-Content-Type-Options "nosniff"

    # Hashed assets (Vite/webpack output): immutable long TTL
    @hashed_assets {
        path_regexp \.[a-f0-9]{8,}\.(js|css|woff2|png|svg)$
    }
    header @hashed_assets Cache-Control "public, max-age=31536000, immutable"

    # API routes: private, no-store
    @api {
        path /api/*
    }
    header @api Cache-Control "private, no-store"
}

CACHING3-002 — Expires: 0 ignored by CDN default TTL

The Expires: 0 and Expires: <past-date> headers were the HTTP/1.0 way to indicate that a response should not be cached. Modern CDNs treat Cache-Control as authoritative over Expires. If the response does not include a Cache-Control header, many CDN configurations apply a default TTL — commonly 1 hour — regardless of the Expires value. An API response that sets only Expires: 0 (or no cache headers at all, which triggers CDN default TTLs) will be cached at the CDN edge and served to subsequent users who request the same URL, potentially exposing private audit results, billing information, or session-specific data to other users.

The correct directive for preventing all caching — at both CDN and browser level — is Cache-Control: no-store. no-store is universally respected by CDNs and browsers alike. Never rely on Expires: 0 alone for sensitive API responses.

// VULNERABLE — Expires: 0 on API response; CDN ignores it and caches under default TTL
import express from 'express';

app.get('/api/audit/:id', auth, async (req, res) => {
  const result = await getAuditResult(req.params.id, req.user.orgId);
  // VULNERABLE: Expires: 0 is ignored by CDN — private audit result cached for ~1hr
  res.set('Expires', '0');
  res.json(result);
});
// FIXED — Cache-Control: private, no-store on all authenticated API responses
import express from 'express';

// Middleware: set no-store on all /api/ routes
app.use('/api/', (req, res, next) => {
  res.set('Cache-Control', 'private, no-store');
  res.set('Pragma', 'no-cache'); // HTTP/1.0 compatibility for proxies
  next();
});

app.get('/api/audit/:id', auth, async (req, res) => {
  const result = await getAuditResult(req.params.id, req.user.orgId);
  // Cache-Control: private, no-store set by middleware — CDNs will not cache this
  res.json(result);
});

// Public cached routes — only these get CDN caching
app.get('/api/public/stats', async (req, res) => {
  const stats = await getPublicStats();
  res.set('Cache-Control', 'public, max-age=300, stale-while-revalidate=60');
  res.set('Vary', 'Accept-Encoding');
  res.json(stats);
});

CACHING3-003 — Surrogate-Control not stripped at CDN; browser receives CDN TTL

Surrogate-Control is a Varnish/CDN-specific header that overrides Cache-Control at the CDN layer. The convention is: CDN uses Surrogate-Control for its TTL, and the CDN is supposed to strip the Surrogate-Control header before forwarding the response to the browser — so the browser sees only the Cache-Control value intended for it. Some CDN configurations do not strip Surrogate-Control. When this happens, the browser receives Surrogate-Control: max-age=3600 and treats it as a caching instruction, caching the response for 1 hour even if the developer intended only the CDN to cache it and the browser to fetch fresh on each visit.

# VULNERABLE: Surrogate-Control set for CDN but not stripped; browser receives it
# Node.js response sets:
# Cache-Control: no-cache
# Surrogate-Control: max-age=3600

# CDN does NOT strip Surrogate-Control before forwarding
# Browser receives both headers and uses Surrogate-Control:max-age=3600
# Browser caches response for 1 hour despite Cache-Control: no-cache intent
# FIXED: Caddy strips Surrogate-Control before forwarding to browser
skillaudit.dev {
    reverse_proxy localhost:3000 {
        # Strip Surrogate-Control from upstream responses before forwarding to browser
        # CDN edge (Cloudflare / Fastly) processes it first, then it's removed
        header_down -Surrogate-Control
    }
}

# Or in Cloudflare Worker / Fastly VCL:
# Remove Surrogate-Control from response before returning to browser
# Fastly VCL:
# sub vcl_deliver {
#   unset resp.http.Surrogate-Control;
# }
// Node.js: explicitly set both Surrogate-Control (for CDN) and Cache-Control (for browser)
// and document that the CDN MUST strip Surrogate-Control
app.get('/seo/:slug', async (req, res) => {
  const page = await getSeoPage(req.params.slug);
  res.set({
    'Cache-Control': 'public, max-age=60, stale-while-revalidate=300', // browser TTL: 60s
    'Surrogate-Control': 'max-age=3600', // CDN TTL: 1 hour (must be stripped by CDN)
    'Vary': 'Accept-Encoding',
  });
  res.send(page);
});

CACHING3-004 — stale-while-revalidate without stale-if-error

stale-while-revalidate=N tells caches to serve stale content while asynchronously revalidating in the background. This eliminates revalidation latency for cache hits but doesn't help when the revalidation itself fails — when the origin returns a 5xx during the revalidation fetch. Without stale-if-error, a revalidation failure causes the cache to immediately forward the error response to the user instead of continuing to serve the now-stale (but correct) content. Under sustained origin load, this means users see 502/503 errors despite the cache having a valid recent response it could serve.

Adding stale-if-error=86400 instructs the cache to continue serving stale content for up to 24 hours if origin returns 5xx during revalidation. This is appropriate for read-heavy MCP skill content like public audit summaries and SEO pages that change slowly — users receive slightly stale data rather than an error page during origin outages.

// VULNERABLE — stale-while-revalidate without stale-if-error
app.get('/api/public/leaderboard', async (req, res) => {
  const data = await getLeaderboard();
  // VULNERABLE: if origin returns 5xx during stale revalidation,
  // cache forwards the error to user instead of serving stale data
  res.set('Cache-Control', 'public, max-age=60, stale-while-revalidate=300');
  res.json(data);
});
// FIXED — stale-if-error allows serving stale content during origin outages
app.get('/api/public/leaderboard', async (req, res) => {
  const data = await getLeaderboard();
  // max-age=60: fresh for 60s
  // stale-while-revalidate=300: serve stale + revalidate in background for 5 more min
  // stale-if-error=86400: serve stale for up to 24hr if origin errors during revalidation
  res.set('Cache-Control', 'public, max-age=60, stale-while-revalidate=300, stale-if-error=86400');
  res.set('Vary', 'Accept-Encoding');
  res.json(data);
});

// Private authenticated routes: no stale-while-revalidate — always fresh from origin
app.get('/api/audit/:id', auth, async (req, res) => {
  const result = await getAuditResult(req.params.id, req.user.orgId);
  res.set('Cache-Control', 'private, no-store'); // never stale for private data
  res.json(result);
});

Related patterns: Cache-Control misconfigurations in MCP skills are often exacerbated by HTTP request smuggling that allows attackers to poison CDN caches for authenticated paths — see SA-SKL-DESYNC1: HTTP request smuggling for the cache poisoning via smuggled GET pattern. For CORS on SSE and WebSocket responses that also interact with the CDN cache layer, see SA-SKL-CORS10. The earlier MCP server cache poisoning blog post covers the broader cache poisoning threat model across HTTP layers.

FindingSeverityVulnerable patternFix
CACHING3-001Highindex.html Cache-Control: max-age=31536000, immutableindex.html: no-cache; hashed assets: immutable; separate by path in Caddy
CACHING3-002HighExpires: 0 on API response; CDN applies default 1hr TTLCache-Control: private, no-store on all authenticated API routes
CACHING3-003MediumSurrogate-Control not stripped; browser receives CDN TTLCaddy header_down -Surrogate-Control; CDN VCL unset resp.http.Surrogate-Control
CACHING3-004Mediumstale-while-revalidate without stale-if-error; errors during revalidationAdd stale-if-error=86400 to public cacheable responses; no-store for private