Caching

Runtime Cache
Runtime Cache
all plans
Runtime cache is a regional, ephemeral cache you can use for storing and retrieving data across Vercel Functions, Routing middleware, and build execution within a Vercel region. It lets you cache data close to where your code runs, reduce duplicate work, and control invalidation with TTLs and tags.
Copy page
- Find out how runtime cache works
- When to use it
- Get started with the framework-specific examples
CDN cache. For caching build artifacts, see
Remote cache.
When to use runtime cache
Runtime cache is best when your functions fetch the same data multiple times or perform expensive computations that can be reused, such as in the following scenarios:
- API calls that return the same data across multiple requests
- Database queries that don't change frequently
- Expensive computations you want to reuse
- Data fetching in server components or API routes
Runtime cache is not a good fit for:
- User-specific data that differs for each request
- Data that must be fresh on every request
- Data that must be retained for its full TTL (entries may be evicted sooner if the cache reaches its storage limit)
- Complete HTTP responses (use CDN cache instead)
How runtime cache works
Runtime cache stores data in a non-durable cache close to where your function executes. Each region where your function runs has its own cache, allowing reads and writes to happen in the same region for low latency. It has the following characteristics:
- Regional: Each region has its own cache
- Isolated by environment: Each deployment environment ( preview and production) uses its own cache, so they never share cached data
- Scoped by plan: On Pro and Enterprise, each project uses its own cache. On Hobby, all projects in your team share a single cache. See storage scope by plan
- Persistent across deployments: Cached data persists across deployments and can be invalidated through time-based expiration or by calling expireTag
- Ephemeral: Each cache has a storage limit. When a cache reaches this limit, Vercel evicts (removes) the entries that haven't been accessed recently to free up space for new entries
- Automatic: When runtime cache is enabled, Vercel handles caching for you
- Framework-agnostic: Works with all frameworks
The cache sits between your function and your data source, reducing the need to repeatedly fetch the same data. See limits and usage for information on item size, tags per item, and maximum tag length.
Using runtime cache
You can cache your Vercel function with any framework by using the functions of the helper method getCache.
Runtime cache with any framework
This example caches data fetched from the API so that it expires after 1 hour and adds a tag to the cache entry so you can invalidate it later from code:
exportdefault {
asyncfetch(request) {
import { getCache } from'@vercel/functions';
if (value) {
constcache=getCache();
// Get a value from cache
constvalue=awaitcache.get('somekey');
}
// Set a value in cache with TTL and tags
returnnewResponse(JSON.stringify(value));
constres=awaitfetch('https://api.vercel.app/blog');
constoriginValue=awaitres.json();
awaitcache.set('somekey', originValue, {
});
},
ttl:3600,// 1 hour in seconds
tags: ['example-tag'],
returnnewResponse(JSON.stringify(originValue));
};
Runtime cache with Next.js
With Next.js, you can use runtime cache or data cache in the following ways:
Next.js version
Next.js 16 and above
Runtime cache
Data cache
Next.js 15
Next.js 14 and below
fetch with force-cache or unstable_cache
With Next.js 16, you can cache data at runtime in two ways:
- use cache: remote: A directive that caches entire functions or components with Runtime cache. Requires enabling cacheComponents in your config.
- fetch with force-cache: Caches individual fetch requests without additional configuration with Data cache.
Use the use cache: remote directive at the file, component, or function level to cache the output of a function or component.
use cache is in-memory by default. This means that it is ephemeral, and disappears when the instance that served the request is shut down.
use cache: remote is a declarative way telling the system to store the cached output in a remote cache such Vercel runtime cache.
First, enable the cacheComponents flag in your next.config.ts file:
importtype { NextConfig } from'next';
constnextConfig:NextConfig= {
cacheComponents:true,
};
exportdefault nextConfig;
Then, use the use cache: remote directive in your code. This example caches data so that it expires after 1 hour and adds a tag to the cache entry so you can invalidate it later from code:
Our Services
import { cacheLife, cacheTag } from'next/cache';
return (
exportdefaultasyncfunctionPage() {
constdata=awaitgetData();
{JSON.stringify(data, null,2)}
);
}
asyncfunctiongetData() {
'use cache: remote'
cacheTag('example-tag')
Software Delivery
}
cacheLife({ expire:3600 }) // 1 hour
constresponse=awaitfetch('https://api.example.com/data');
returnresponse.json();
Data
You can also use runtime cache in API routes:
}
exportasyncfunctionGET() {
returnResponse.json(data);
import { cacheLife } from'next/cache';
constdata=awaitgetProducts();
asyncfunctiongetProducts() {
}
'use cache: remote'
returnresponse.json();
cacheLife({ expire:3600 }) // 1 hour
constresponse=awaitfetch('https://api.example.com/products');
Using fetch with force-cache
If you don't enable cacheComponents, you can use fetch with cache: 'force-cache' to cache individual fetch requests:
next: {
tags: ['blog'],
},
cache:'force-cache',
constres=awaitfetch('https://api.example.com/blog', {
constdata=awaitres.json();
revalidate:3600,// revalidate in background every hour
});
return (
exportdefaultasyncfunctionPage() {
{JSON.stringify(data, null,2)}
Next.js 15
In Next.js 15, use the fetch() API with cache: 'force-cache' or unstable_cache to store data in Data cache.
Using fetch with cache options
Use cache: 'force-cache' to persist data in the cache:
}
});
cache:'force-cache',
constres=awaitfetch('https://api.example.com/blog', {
constdata=awaitres.json();
);
return (
exportdefaultasyncfunctionPage() {
{JSON.stringify(data, null,2)}
For time-based revalidation, combine cache: 'force-cache' with the next.revalidate option:
next: {
});
},
cache:'force-cache',
constres=awaitfetch('https://api.example.com/blog', {
constdata=awaitres.json();
revalidate:3600,// revalidate in background every hour
);
return (
exportdefaultasyncfunctionPage() {
{JSON.stringify(data, null,2)}
For tag-based revalidation, combine cache: 'force-cache' with the next.tags option:
next: {
});
},
cache:'force-cache',
tags: ['blog'],
constdata=awaitres.json();
constres=awaitfetch('https://api.example.com/blog', {
);
return (
exportdefaultasyncfunctionPage() {
{JSON.stringify(data, null,2)}
Then invalidate the cache using revalidateTag:
'use server';
import { revalidateTag } from'next/cache';
exportasyncfunctioninvalidateBlog() {
revalidateTag('blog');
}
For non-fetch data sources, use unstable_cache:
import { unstable_cache } from'next/cache';
revalidate:3600,// 1 hour
exportdefaultasyncfunctionPage() {
// Fetch from database, API, or other source
return (
constdata=awaitdb.query('SELECT * FROM posts');
},
{
}
['posts'],// Cache key
return data;
);
constdata=awaitgetCachedData();
);
tags: ['posts'],
async () => {
}
If you're using Next.js 14 or below, see Data Cache for the legacy caching approach or use the framework-agnostic getCache function.
You can control how long data stays cached using the following revalidation options:
This example revalidates the cache every hour:
TypeScript

returnresponse.json();
}
exportasyncfunctionGET() {
returnResponse.json(data);
Next.js (/app)

import { cacheLife } from'next/cache';
asyncfunctiongetProducts() {
}
'use cache: remote'
constresponse=awaitfetch('https://api.example.com/products');
constdata=awaitgetProducts();
cacheLife({ expire:3600 }) // 1 hour
This example associates the products tag with the data:
TypeScript

'use cache: remote'
asyncfunctiongetProducts() {
constdata=awaitgetProducts();
returnResponse.json(data);
Next.js (/app)

import { cacheLife, cacheTag } from'next/cache';
}
}
cacheTag('products')
returnresponse.json();
cacheLife({ expire:3600 }) // 1 hour
constresponse=awaitfetch('https://api.example.com/products');
import { revalidateTag } from'next/cache';
revalidateTag('products');
You can then revalidate the cache for any data associated with the products tag by using the revalidateTag function. For example, use a server action:
exportasyncfunctioninvalidateProductsCache() {
This example revalidates the cache for the /products path using a server action:
import { revalidatePath } from'next/cache';
exportasyncfunctionPOST() {
revalidatePath('/products');
}
Working with CDN cache
Runtime cache can work alongside CDN caching in two ways:
- With Vercel ISR: Vercel handles CDN caching for your pages and routes, while runtime cache stores the data fetches within your functions
- With manual CDN caching (shown below): You set Cache-Control headers to cache HTTP responses at the CDN, while runtime cache stores data fetches within your functions
This section covers the manual approach. If you're using Vercel ISR, runtime cache operates independently as described in limits and usage.
When you've set up runtime cache with a serverless function and manual CDN caching, the following happens:
- Your function runs and checks the runtime cache in the region where it is executed for data
- If that region's runtime cache has the data, it returns the data immediately
- If not, your function fetches the data from origin and stores it in that region's runtime cache
- Your function generates a response using the data
- If you configured CDN cache via Cache-Control headers, it will cache the complete response in Vercel regions
This example uses runtime cache to fetch and cache product data, and CDN cache to cache the complete API response:
Our Services
constresponse=awaitfetch('https://api.example.com/products');
import { cacheLife } from'next/cache';
status:200,
exportasyncfunctionGET() {
constproducts=awaitgetProducts();
returnnewResponse(JSON.stringify(products), {
},
});
'Content-Type':'application/json',
'Cache-Control':'public, s-maxage=60',// CDN caches for 60 seconds
headers: {
'use cache: remote'// Runtime cache
Software Delivery
}
}
cacheLife({ expire:3600 }) // 1 hour
asyncfunctiongetProducts() {
returnresponse.json();
Observability
In this example:
You can observe your project's Runtime cache usage in the Runtime Cache section of the Observability section in the sidebar under your project in the Vercel dashboard.
You can reach our customer support team by emailing info@yourcompany.example.com, calling +1 555-555-5556, or using the live chat on our website. Our dedicated team is available 24/7 to assist with any inquiries or issues.
We’re committed to providing prompt and effective solutions to ensure your satisfaction.
We offer a 30-day return policy for all products. Items must be in their original condition, unused, and include the receipt or proof of purchase. Refunds are processed within 5-7 business days of receiving the returned item.
Limits and usage
Runtime Cache property
Is the website user-friendly?
You can also see a tabular list of runtime cache tags used in your project with cache reads, writes, hit rate, and revalidation times.
Limit
2 MB
Item size
Maximum tag length
Tags per item
128 tags
256 bytes
Each project uses its own cache
Runtime cache storage
Can you trust our partners?
Runtime cache operates independently from Incremental Static Regeneration. If you use both caching layers, manage them separately using their respective invalidation methods or use the same cache tag for both to manage them together.
Pro
Enterprise
Hobby
Your plan determines whether your projects share a single runtime cache or whether each project gets its own:
All projects in your team share a single cache
Each project uses its own cache
Storage and eviction
Last updated August 28, 2026
Usage of runtime cache is charged. Learn more about pricing.
Every plan splits the cache by deployment environment, so production and preview never share cached data. Runtime cache and Data cache also use separate storage, so they don't compete for the same space.
Data Cache
On Hobby, where your projects share a cache, they share its storage limit and its eviction policy. A project that writes a lot of data can evict entries that belong to your other projects.
Cross-link map: Runtime Cache (/docs/caching/runtime-cache)From the Vercel docs graph (built 2026-09-21T05:26:59.511Z), spanning vercel.com docs + KB, nextjs.org, ai-sdk.dev, and other Vercel documentation sites. Full graph as JSON: https://vercel.com/docs/graph.jsonSemantically closest pagesData Cache for Next.js — Vercel Data Cache is a specialized cache that stores responses from data fetches in Next.js App Router@vercel/functions API Reference \(Node.js\) — Learn about available APIs when working with Vercel Functions.Caching — Learn how Vercel caches content across multiple layers to deliver fast responses and reduce load on your backend.Vercel Data Cache: A progressive cache, integrated with Next.jsIncremental Static Regeneration \(ISR\) — ISR serves cached static pages while regenerating content in the background. Vercel\\PrerequisitesCaching — Learn how Vercel caches content across multiple layers to deliver fast responses and reduce load on your backend.This page links to (7)Vercel CDN Cache — Learn how Vercel's CDN cache stores your content across a global network to reduce latency and origin load.Data Cache for Next.js — Vercel Data Cache is a specialized cache that stores responses from data fetches in Next.js App Router@vercel/functions API Reference \(Node.js\) — Learn about available APIs when working with Vercel Functions.Incremental Static Regeneration \(ISR\) — ISR serves cached static pages while regenerating content in the background. Vercel\\Remote Caching — Vercel Remote Cache allows you to share build outputs and artifacts across distributed teams.Regional Pricing — Vercel pricing for Managed Infrastructure resources in different regions.Global network and regions — View the list of regions supported by Vercel's CDN and learn about our global infrastructure.Pages that link here (45)By site: vercel-changelog (1) · vercel-kb (4) · vercel-docs (40)From vercel-changelogRun background tasks with Celery on VercelFrom vercel-kbCaching audits: Five antipatterns that cost performance and money — Five caching antipatterns from hundreds of Vercel technical audits: write amplification, deploy-wiped caches, spinner shHow to add per-request CSP nonces to CDN-cached HTML on Vercel — Use Routing Middleware and a self-fetch to add a fresh CSP nonce to cached HTML without rendering the page again on everTroubleshoot and optimize Active CPU usage on Fluid compute — Diagnose which routes drive Active CPU usage and learn to optimize it. Separate traffic growth from per-request CPU workBuild a Weather API on Vercel: Express, FastAPI, and Nitro — Build a weather API on Vercel with FastAPI, Express, or Nitro. Compare the three runtimes, add caching and ObservabilityFrom vercel-docsCaching — Learn how Vercel caches content across multiple layers to deliver fast responses and reduce load on your backend.Cache Status and Reasons — Understand the cache status and reason shown for each request in Vercel logs, and what causes a response to miss, bypassVercel CDN Cache — Learn how Vercel's CDN cache stores your content across a global network to reduce latency and origin load.Data Cache for Next.js — Vercel Data Cache is a specialized cache that stores responses from data fetches in Next.js App RouterVercel CDN overview — Vercel's CDN is a globally distributed platform that handles routing, caching, security, and compression for every deplovercel cache — Learn how to manage cache for your project using the vercel cache CLI command.Frameworks on Vercel — Vercel supports a wide range of the most popular frameworks, optimizing how your application builds and runs no matter wRun background tasks with Celery on Vercel — Deploy Celery on Vercel. Learn how Celery workers use Vercel Queues and Vercel Functions to run background tasks withoutDeploy Dramatiq workers on Vercel — Deploy Dramatiq workers on Vercel. Learn how Dramatiq actors use Vercel Queues and Vercel Functions to process backgrounFrontends on Vercel — Vercel supports a wide range of the most popular frontend frameworks, optimizing how your application builds and runs noFull-stack frameworks on Vercel — Vercel supports a wide range of the most popular backend frameworks, optimizing how your application builds and runs noSupported Frameworks on Vercel — Learn about the frameworks that can be deployed to Vercel.Functions API Reference — Learn about available APIs when working with Vercel Functions.@vercel/functions API Reference \(Node.js\) — Learn about available APIs when working with Vercel Functions.vercel.functions API Reference \(Python\) — Learn about available APIs when working with Vercel Functions in Python.Response headers — Learn about the response headers sent to each Vercel deployment and how to use them to process responses before sendingHow Vercel CDN works — Learn how Vercel's CDN processes requests through routing, caching, and compute layers to deliver your content with lowIncremental Static Regeneration \(ISR\) — ISR serves cached static pages while regenerating content in the background. Vercel\\Partial Prerendering \(PPR\) — Partial Prerendering serves a cached static shell instantly, then renders and streams the dynamic parts of a page per reCalculating usage of resources — Understand how Vercel measures and calculates your resource usage based on a typical user journey.Manage and optimize usage — Understand how to manage and optimize your usage on Vercel, learn how to track your usage, set up alerts, and optimize yStockholm, Sweden \(arn1\) pricing — Vercel pricing for the Stockholm, Sweden \(arn1\) region.Mumbai, India \(bom1\) pricing — Vercel pricing for the Mumbai, India \(bom1\) region.Paris, France \(cdg1\) pricing — Vercel pricing for the Paris, France \(cdg1\) region.Cleveland, USA \(cle1\) pricing — Vercel pricing for the Cleveland, USA \(cle1\) region.Cape Town, South Africa \(cpt1\) pricing — Vercel pricing for the Cape Town, South Africa \(cpt1\) region.Dublin, Ireland \(dub1\) pricing — Vercel pricing for the Dublin, Ireland \(dub1\) region.Frankfurt, Germany \(fra1\) pricing — Vercel pricing for the Frankfurt, Germany \(fra1\) region.São Paulo, Brazil \(gru1\) pricing — Vercel pricing for the São Paulo, Brazil \(gru1\) region.Hong Kong \(hkg1\) pricing — Vercel pricing for the Hong Kong \(hkg1\) region.Tokyo, Japan \(hnd1\) pricing — Vercel pricing for the Tokyo, Japan \(hnd1\) region.Washington D.C., USA \(iad1\) pricing — Vercel pricing for the Washington D.C., USA \(iad1\) region.Seoul, South Korea \(icn1\) pricing — Vercel pricing for the Seoul, South Korea \(icn1\) region.Osaka, Japan \(kix1\) pricing — Vercel pricing for the Osaka, Japan \(kix1\) region.London, UK \(lhr1\) pricing — Vercel pricing for the London, UK \(lhr1\) region.Portland, USA \(pdx1\) pricing — Vercel pricing for the Portland, USA \(pdx1\) region.San Francisco, USA \(sfo1\) pricing — Vercel pricing for the San Francisco, USA \(sfo1\) region.Singapore \(sin1\) pricing — Vercel pricing for the Singapore \(sin1\) region.Sydney, Australia \(syd1\) pricing — Vercel pricing for the Sydney, Australia \(syd1\) region.Montréal, Canada \(yul1\) pricing — Vercel pricing for the Montréal, Canada \(yul1\) region.
Was this helpful?