---
title: Set cache control headers for functions
description: Learn how to set headers to cache your function's responses.
url: /kb/guide/set-cache-control-headers
canonical_url: "https://vercel.com/kb/guide/set-cache-control-headers"
published: 2025-11-04
last_updated: 2026-07-16
authors: DX Team
related:
  - /docs/headers
  - /docs/edge-cache
  - /docs/incremental-static-regeneration
install_vercel_plugin: npx plugins add vercel/vercel-plugin
---
<!-- docsgraph:related -->
## Related pages

> **For AI agents:** Follow these links to understand how this page connects to the rest of the Vercel ecosystem. For the full cross-link map (inbound, outbound, prerequisites, and semantic neighbors), see the .graph.md link below.

- [Cache-Control Headers](https://vercel.com/docs/caching/cache-control-headers?from=related) — Learn about the cache-control headers sent to each Vercel deployment and how to use them to control the caching behavior
- [CDN Cache](https://vercel.com/docs/caching/cdn-cache?from=related) — Learn how Vercel's CDN cache stores your content across a global network to reduce latency and origin load.
- [Caching](https://vercel.com/docs/caching?from=related) — Learn how Vercel caches content across multiple layers to deliver fast responses and reduce load on your backend.
- [Response Headers](https://vercel.com/docs/headers/response-headers?from=related) — Learn about the response headers sent to each Vercel deployment and how to use them to process responses before sending
- [Data Cache](https://vercel.com/docs/caching/runtime-cache/data-cache?from=related) — Vercel Data Cache is a specialized cache that stores responses from data fetches in Next.js App Router
- [How to Configure the Cache-Control Response Header in Vercel Projects](https://vercel.com/kb/guide/how-to-configure-the-cache-control-response-header-in-vercel-projects?from=related) — After reviewing this guide, you will be able to set a cache-control header of any value to be returned when a specific p
- [Manage cache tags for external origins](https://vercel.com/kb/guide/how-to-manage-cache-tags-for-external-origins?from=related) — Learn how to use cache tags to optimally serve fresh content on Vercel when content from your external origin changes

Full cross-link map for this page: [/kb/guide/set-cache-control-headers.graph.md](/kb/guide/set-cache-control-headers.graph.md)
<!-- /docsgraph:related -->


By default, the CDN and browser will not cache, unless you set the following headers in your function as needed: `Cache-Control`,`CDN-Cache-Control`, and `Vercel-CDN-Cache-Contol`. You can set these headers to:

- [Set the cache depending on location](#set-caching-depending-on-location)
  
- [Set the same cache duration everywhere](#same-cache-duration-everywhere)
  
- [Set caching for Vercel's Cache](#set-caching-for-vercel's-cache)
  
- [Set caching for all CDNs](#set-caching-for-all-cdns)
  

Setting the cache in functions takes priority over config files.

### Set caching depending on location

```javascript
export async function GET() {
  return new Response('Cache Control example', {
    status: 200,
    headers: {
      'Cache-Control': 'max-age=10',
      'CDN-Cache-Control': 'max-age=60',
      'Vercel-CDN-Cache-Control': 'max-age=3600',
    },
  });
}
```
```typescript
export async function GET() {
  return new Response('Cache Control example', {
    status: 200,
    headers: {
      'Cache-Control': 'max-age=10',
      'CDN-Cache-Control': 'max-age=60',
      'Vercel-CDN-Cache-Control': 'max-age=3600',
    },
  });
}
```

Vercel uses the following priority when you specify multiple cache control headers:

- `Vercel-CDN-Cache-Control`
  
- `CDN-Cache-Control`
  
- `Cache-Control`
  

### Same cache duration everywhere

This sets the same maximum cache duration for Vercel, CDNs, and the client:

```javascript
export async function GET() {
  return new Response('Cache Control example', {
    status: 200,
    headers: {
      'Cache-Control': 'max-age=3600',
    },
  });
}
```
```typescript
export async function GET() {
  return new Response('Cache Control example', {
    status: 200,
    headers: {
      'Cache-Control': 'max-age=3600',
    },
  });
}
```

### Set caching for Vercel's Cache

This sets the maximum cache duration for Vercel's Cache only.

```javascript
export async function GET() {
  return new Response('Cache Control example', {
    status: 200,
    headers: {
      'Vercel-CDN-Cache-Control': 'max-age=3600',
    },
  });
}
```
```typescript
export async function GET() {
  return new Response('Cache Control example', {
    status: 200,
    headers: {
      'Vercel-CDN-Cache-Control': 'max-age=3600',
    },
  });
}
```

### Set caching for all CDNs

This sets the cache duration on Vercel and also on other CDNs

```javascript
export async function GET() {
  return new Response('Cache Control example', {
    status: 200,
    headers: {
      'CDN-Cache-Control': 'max-age=60',
    },
  });
}
```
```typescript
export async function GET() {
  return new Response('Cache Control example', {
    status: 200,
    headers: {
      'CDN-Cache-Control': 'max-age=60',
    },
  });
}
```

## More resources

- [Caching Headers](/docs/headers#cache-control-header)
  
- [Vercel Cache](/docs/edge-cache)
  
- [ISR](/docs/incremental-static-regeneration)