Skip to content
netlify avatar

Netlify Caching

Netlify CDN caching controls for function and edge responses, including headers, purges, and the Cache API.

CCM score
77 of 100
skills.sh installs
3.5K
GitHub stars
57
last updated
Aug 21, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers Netlify-CDN-Cache-Control directives, Netlify-Vary cache-key rules, cache tags, and durable caching for serverless functions
  • Includes on-demand purging by site or tag via purgeCache, the purge REST endpoint, and the programmatic caches Cache API
  • Enforces that static assets stay fresh up to a year and durable has no effect on Edge Function responses
  • Designed for developers adding caching or invalidation to Netlify Functions, Edge Functions, or proxied API responses

Install

$ npx -y skills add netlify/context-and-tools --skill netlify-caching -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

Netlify caching

Cache-control header to reach for

Dynamic responses (Functions, Edge Functions, Netlify Server, proxies) are NOT cached by default. You must opt in. Set Netlify-CDN-Cache-Control on the response:

import type { Context } from "@netlify/functions";

export default async (req: Request, context: Context) => {
  return new Response("Hello world", {
    headers: {
      'Netlify-CDN-Cache-Control': 'public, durable, max-age=60, stale-while-revalidate=120'
    }
  });
};

Header choice (most specific wins; CDN-Cache-Control/Cache-Control always pass downstream):

  • Netlify-CDN-Cache-Control applies to the Netlify CDN only. Reach for this.
  • CDN-Cache-Control applies to all CDNs that support it.
  • Cache-Control applies to any CDN or the browser.

Legacy path to avoid: On-demand Builders do not support these headers or Netlify-Vary. They use a TTL pattern and key on URL path only. Don't reach for ODBs in new code.

Footguns (read first)

Details

Repository
github.com/netlify/context-and-tools
Categories
Backend & APIs, DevOps & Cloud
First seen
Jun 3, 2026

Questions

What does the netlify-caching skill help with?

The netlify-caching skill guides you on controlling caching on Netlify's CDN for functions, edge functions, and Netlify Server responses. It covers Netlify-CDN-Cache-Control headers, stale-while-revalidate, cache tags, purging, the durable cache, and the programmatic Cache API.

How do I install the netlify-caching skill?

Run npx -y skills add netlify/context-and-tools --skill netlify-caching -y in your project. After that, the agent can apply Netlify caching patterns such as cache headers, cache key variation, and on-demand purges to your code.

Why is my Netlify function response not being cached?

Dynamic responses from functions are not cached by default, so you must set a Netlify-CDN-Cache-Control header to opt in. The skill also explains reading the Cache-Status header to debug whether a response is cached.

Where does netlify-caching stand in the Backend & APIs category?

The netlify-caching skill is listed in the Backend & APIs category on Claude Marketplaces. Its focus on CDN cache control, purging, and cache tags sets it apart from general API skills in that category.

More from netlify/context-and-tools

All 12

Similar to Netlify Caching

More Backend & APIs