Agent Native

runtime-cache

This skill provides guidance on Vercel's Runtime Cache API, an ephemeral per-region key-value store with tag-based invalidation for caching data across…

by VercelOfficial publisherNot reviewed

Identity proven by GitHub's verified organisation badge (vercel, vercel-labs)

Agents
Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode
License
Apache-2.0 (permissive)
Pin
2a1e58dpinned Oct 9, 2026
Context cost
about 1,800 tokenswhen the skill loads
GitHub stars
300on vercel/vercel-plugin
Scripts
None found

What it does

“Vercel Runtime Cache API guidance — ephemeral per-region key-value cache with tag-based invalidation. Shared across Functions, Routing Middleware, and Builds. Use when implementing caching strategies beyond framework-level caching.”
The author's description, from SKILL.md

Generated summary from the skill's own text

This skill provides guidance on Vercel's Runtime Cache API, an ephemeral per-region key-value store with tag-based invalidation for caching data across Functions, Middleware, and Builds. It covers cache operations, tag management, integration with Next.js 16+, CLI commands, and limits to help implement caching strategies beyond framework defaults.

When to use it

  • Cache API responses or computed data shared across functions
  • Invalidate cache by tags when content changes via webhooks
  • Reduce database load for frequently accessed regional data
  • Share data between functions within a region without persistence

When not to

  • Use Next.js Cache Components for framework-level page caching instead
  • Need persistent storage across deployments or regions
  • Want full response caching at CDN level with standard headers

Install

These commands install from the publisher's repository and need no account.

skills CLI

npx skills add vercel/vercel-plugin --skill runtime-cache

Installs from the repository's default branch, which may have changed since the commit we checked.

GitHub CLI 2.90 or later

gh skill install vercel/vercel-plugin runtime-cache@2a1e58dfb63c064c2589c0c21b3e93c53728f8d5

Installs the commit we checked (2a1e58d).

Copy by hand

Download the folder at 2a1e58d and put it in .claude/skills/runtime-cache for Claude Code and in .agents/skills/runtime-cache for Codex, Cursor, Gemini CLI, GitHub Copilot and OpenCode.

Skill folder on GitHub at 2a1e58d

Claude Code plugin

/plugin install vercel@claude-plugins-official

The publisher's plugin in Claude's official marketplace. It may hold more than this skill, and we have not pinned it.

Copy for your agent

A prompt for any coding agent. It installs this skill from GitHub at the pinned commit, copies the files as they are, and runs nothing unless you ask.

Prompt

Install the agent skill "runtime-cache" by Vercel.

Source, pinned to commit 2a1e58dfb63c064c2589c0c21b3e93c53728f8d5:
https://github.com/vercel/vercel-plugin/tree/2a1e58dfb63c064c2589c0c21b3e93c53728f8d5/skills/runtime-cache

1. Download that folder at exactly this commit. Do not use the default branch.
2. Copy every file unchanged, keeping the folder structure, into .claude/skills/runtime-cache/ for Claude Code and .agents/skills/runtime-cache/ for Codex, Cursor, Gemini CLI, GitHub Copilot and OpenCode. Create the folders if they do not exist.
3. Do not edit the files, and do not run any script in the folder unless I ask you to.
4. When you are done, list the files you copied and where you put them.

Listing and checks: https://www.agentnative.dev/skills/vercel/runtime-cache

SKILL.md at the pin

---
name: runtime-cache
description: Vercel Runtime Cache API guidance — ephemeral per-region key-value cache with tag-based invalidation. Shared across Functions, Routing Middleware, and Builds. Use when implementing caching strategies beyond framework-level caching.
metadata:
  priority: 6
  docs:
    - "https://nextjs.org/docs/app/api-reference/directives/use-cache-remote"
  sitemap: "https://nextjs.org/sitemap.xml"
  pathPatterns: 
    - 'lib/cache/**'
    - 'src/lib/cache/**'
    - 'lib/cache.*'
    - 'src/lib/cache.*'
  bashPatterns:
    - '\bnpm\s+(install|i|add)\s+[^\n]*@vercel/functions\b'
    - '\bpnpm\s+(install|i|add)\s+[^\n]*@vercel/functions\b'
    - '\bbun\s+(install|i|add)\s+[^\n]*@vercel/functions\b'
    - '\byarn\s+add\s+[^\n]*@vercel/functions\b'
validate:
  -
    pattern: 'from\s+[''""](redis|ioredis)[''""]|require\s*\(\s*[''""](redis|ioredis)[''""]|new\s+Redis\('
    message: 'Direct Redis/ioredis client detected. Use Upstash Redis (@upstash/redis) for serverless-native Redis with HTTP-based connections.'
    severity: recommended
    upgradeToSkill: vercel-storage
    upgradeWhy: 'Replace direct Redis/ioredis with @upstash/redis for serverless-compatible HTTP-based Redis that works without persistent TCP connections.'
    skipIfFileContains: 'from\s+[''""]\@upstash/redis[''""]'
retrieval:
  aliases:
    - cache api
    - kv cache
    - region cache
    - tag invalidation
  intents:
    - add caching
    - cache api response
    - invalidate cache
    - set up runtime cache
  entities:
    - Runtime Cache
    - tag-based invalidation
    - key-value
    - cache
chainTo:
  -
    pattern: 'from\s+[''""]@vercel/kv[''""]'
    targetSkill: vercel-storage
    message: '@vercel/kv is sunset — loading Vercel Storage guidance for Upstash Redis migration.'
  -
    pattern: 'from\s+[''""]ioredis[''""]|new\s+Redis\('
    targetSkill: vercel-storage
    message: 'Direct Redis client detected — loading Vercel Storage guidance for Upstash Redis (serverless-native) integration.'

---

# Vercel Runtime Cache API

You are an expert in the Vercel Runtime Cache — an ephemeral caching layer for serverless compute.

## What It Is

The Runtime Cache is a **per-region key-value store** accessible from Vercel Functions, Routing Middleware, and Builds. It supports **tag-based invalidation** for granular cache control.

- **Regional**: Each Vercel region has its own isolated cache
- **Isolated**: Scoped per deployment environment (`preview` vs `production`); scoped per project on Pro/Enterprise, but shared across all projects on a Hobby team
- **Persistent across deployments**: Cached data survives new deploys; invalidation via TTL or `expireTag`
- **Ephemeral**: Fixed storage limit per project; LRU eviction when full
- **Framework-agnostic**: Works with any framework via `@vercel/functions`

## Key APIs

All APIs from `@vercel/functions`:

### Basic Cache Operations

```ts
import { getCache } from '@vercel/functions';

const cache = getCache();

// Store data with TTL and tags
await cache.set('user:123', userData, {
  ttl: 3600,                      // seconds
  tags: ['users', 'user:123'],    // for bulk invalidation
  name: 'user-profile',           // human-readable label for observability
});

// Retrieve cached data (returns value or null)
const data = await cache.get('user:123');

// Delete a specific key
await cache.delete('user:123');

// Expire all entries with a tag (propagates globally within 300ms)
await cache.expireTag('users');
await cache.expireTag(['users', 'user:123']); // multiple tags
```

### Cache Options

```ts
const cache = getCache({
  namespace: 'api',                    // prefix for keys
  namespaceSeparator: '$',             // separator (default)
  keyHashFunction: (key) => sha256(key), // custom key hashing
});
```

### Full Example (Framework-Agnostic)

```ts
import { getCache } from '@vercel/functions';

export default {
  async fetch(request: Request) {
    const cache = getCache();
    const cached = await cache.get('blog-posts');

    if (cached) {
      return Response.json(cached);
    }

    const posts = await fetch('https://api.example.com/posts').then(r => r.json());

    await cache.set('blog-posts', posts, {
      ttl: 3600,
      tags: ['blog'],
    });

    return Response.json(posts);
  },
};
```

### Tag Expiration from Server Action

```ts
'use server';
import { getCache } from '@vercel/functions';

export async function invalidateBlog() {
  await getCache().expireTag('blog');
}
```

## CDN Cache Purging Functions

These purge across **all three cache layers** (CDN + Runtime Cache + Data Cache):

```ts
import { invalidateByTag, dangerouslyDeleteByTag } from '@vercel/functions';

// Stale-while-revalidate: serves stale, revalidates in background
await invalidateByTag('blog-posts');

// Hard delete: next request blocks while fetching from origin (cache stampede risk)
await dangerouslyDeleteByTag('blog-posts', {
  revalidationDeadlineSeconds: 3600,
});
```

**Important distinction**:
- `cache.expireTag()` — operates on Runtime Cache only
- `invalidateByTag()` / `dangerouslyDeleteByTag()` — purges CDN + Runtime + Data caches

## Next.js Integration

### Next.js 16+ (`use cache: remote`)

```ts
// next.config.ts
const nextConfig: NextConfig = { cacheComponents: true };
```

```ts
import { cacheLife, cacheTag } from 'next/cache';

async function getData() {
  'use cache: remote'     // stores in Vercel Runtime Cache
  cacheTag('example-tag')
  cacheLife({ expire: 3600 })
  return fetch('https://api.example.com/data').then(r => r.json());
}
```

- `'use cache'` (no `: remote`) — in-memory only, ephemeral per instance
- `'use cache: remote'` — stores in Vercel Runtime Cache

### Next.js 16 Invalidation APIs

| Function | Context | Behavior |
|----------|---------|----------|
| `updateTag(tag)` | Server Actions only | Immediate expiration, read-your-own-writes |
| `revalidateTag(tag, 'max')` | Server Actions + Route Handlers | Stale-while-revalidate (recommended) |
| `revalidateTag(tag, { expire: 0 })` | Route Handlers (webhooks) | Immediate expiration from external triggers |

**Important**: Single-argument `revalidateTag(tag)` is deprecated in Next.js 16. Always pass a `cacheLife` profile as the second argument.

### Runtime Cache vs ISR Isolation

- Runtime Cache tags do **NOT** apply to ISR pages
- `cache.expireTag` does **NOT** invalidate ISR cache
- Next.js `revalidatePath` / `revalidateTag` does **NOT** invalidate Runtime Cache
- To manage both, use same tag and purge via `invalidateByTag` (hits all cache layers)

## CLI Cache Commands

```bash
# Purge all cached data
vercel cache purge                    # CDN + Data cache
vercel cache purge --type cdn         # CDN only
vercel cache purge --type data        # Data cache only
vercel cache purge --yes              # skip confirmation

# Invalidate by tag (stale-while-revalidate)
vercel cache invalidate --tag blog-posts,user-profiles

# Hard delete by tag (blocks until revalidated)
vercel cache dangerously-delete --tag blog-posts
vercel cache dangerously-delete --tag blog-posts --revalidation-deadline-seconds 3600

# Image invalidation
vercel cache invalidate --srcimg /images/hero.jpg
```

Note: `--tag` and `--srcimg` cannot be used together.

## CDN Cache Tags

Add tags to CDN cached responses for later invalidation:

```ts
import { addCacheTag } from '@vercel/functions';

// Via helper
addCacheTag('product-123');

// Via response header
return Response.json(product, {
  headers: {
    'Vercel-CDN-Cache-Control': 'public, max-age=86400',
    'Vercel-Cache-Tag': 'product-123,products',
  },
});
```

## Limits

| Property | Limit |
|----------|-------|
| Item size | 2 MB |
| Tags per Runtime Cache item | 128 |
| Tags per CDN item | 128 |
| Max tag length | 256 bytes |
| Tags per bulk REST API call | 16 |

Tags are **case-sensitive** and **cannot contain commas**.

## Observability

Monitor hit rates, invalidation patterns, and storage usage in the Vercel Dashboard under **Observability → Runtime Cache**. The CDN dashboard (March 5, 2026) provides a unified view of global traffic distribution, cache performance metrics, a redesigned purging interface, and **project-level routing** — update response headers or rewrite to external APIs without triggering a new deployment. Project-level routes are available on all plans and take effect instantly.

## When to Use

- Caching API responses or computed data across functions in a region
- Tag-based invalidation when content changes (CMS webhook → expire tag)
- Reducing database load for frequently accessed data
- Cross-function data sharing within a region

## When NOT to Use

- Framework-level page caching → use Next.js Cache Components (`'use cache'`)
- Persistent storage → use a database (Neon, Upstash)
- CDN-level full response caching → use `Cache-Control` / `Vercel-CDN-Cache-Control` headers
- Cross-region shared state → use a database
- User-specific data that differs per request

## References

- 📖 docs: https://vercel.com/docs/caching/runtime-cache
- 📖 changelog: https://vercel.com/changelog/introducing-the-runtime-cache-api
- 📖 CLI cache: https://vercel.com/docs/cli/cache
- 📖 CDN cache purging: https://vercel.com/docs/caching/cdn-cache/purge

From vercel/vercel-plugin at 2a1e58d, shown as plain text under its license: Apache-2.0 (permissive). The license text is in LICENSE.

View SKILL.md on GitHub at 2a1e58d

Files

2 files, 9.3 KB in total. Each file has a sha256 in the pin's manifest; the first 12 characters are shown.

Skill folder on GitHub at 2a1e58d
All 50 skills from Vercel

More from Vercel

  • next-bundle-optimizer

    Audits Next.js applications to identify and reduce browser bundle size and initial-load work by analyzing routes, dependencies and client outputs.

    Claude Code, Codex, Cursor +4 · about 2.3K tokens · pinned 6 days ago

  • next-cache-components-optimizer

    Optimize Next.js routes to display meaningful UI instantly on initial load or client navigation by encoding the optimization goal as a failing…

    Claude Code, Codex, Cursor +4 · about 5.6K tokens · pinned 6 days ago

  • next-partial-prefetching-adoption

    Enables Partial Prefetching in Next.js 16.3+ apps and guides adoption through auditing Link prefetch behavior, preserving UI in tests or manually, and…

    Claude Code, Codex, Cursor +4 · about 6.7K tokens · pinned 6 days ago

  • next-partial-prefetching-optimizer

    This skill optimizes Next.js client-side navigation under Partial Prefetching by defining what UI loads before and after a click.

    Claude Code, Codex, Cursor +4 · about 2.8K tokens · pinned 6 days ago

  • apple

    This skill emulates Apple's OAuth and OIDC services for local development and testing.

    Claude Code, Codex, Cursor +4 · about 1.9K tokens · pinned 6 days ago

  • aws

    This skill emulates AWS cloud services locally, providing S3 bucket and object operations, SQS message queues, IAM user and role management, and STS assume…

    Claude Code, Codex, Cursor +4 · about 2.8K tokens · pinned 6 days ago

All Cloud and DevOps skills
  • bootstrap

    This skill orchestrates the setup process for Vercel-linked repositories by executing project linking, environment provisioning, database configuration, and…

    by VercelOfficial publisher

    Claude Code, Codex, Cursor +3 · about 1.5K tokens · pinned 6 days ago

  • env-vars

    This skill guides agents through Vercel environment variable management, including .env file hierarchy, the vercel env CLI commands for…

    by VercelOfficial publisher

    Claude Code, Codex, Cursor +3 · about 2.7K tokens · pinned 6 days ago

  • knowledge-update

    Provides Vercel platform knowledge corrections for October 2026, including runtime deprecations, new products, and configuration changes.

    by VercelOfficial publisher

    Claude Code, Codex, Cursor +4 · about 2.5K tokens · pinned 6 days ago

  • vercel-functions

    Vercel Functions expert guidance for Node.js/Bun/Python/Rust serverless functions on Fluid Compute.

    by VercelOfficial publisher

    Claude Code, Codex, Cursor +3 · about 8.9K tokens · pinned 6 days ago

  • nextjs-on-cloudflare

    This skill guides agents to build and deploy Next.js applications on Cloudflare Workers using vinext, a Vite-based reimplementation of Next.js.

    by CloudflareOfficial publisher

    Claude Code, Codex, Cursor +4 · about 560 tokens · pinned 6 days ago

  • vercel

    This skill deploys and manages Vercel applications, handling deployments, aliases, logs, and monitoring.

    by SentryOfficial publisher

    Claude Code, Codex, Cursor +4 · about 610 tokens · pinned 6 days ago

Open roles at Vercel

5 of 11 open roles on the jobs board

The skills listed here are third-party software, collected from public GitHub repositories as a catalog of recent skills and provided as is. Agent Native does not write or control them and is not responsible for any harm, loss or damage caused by installing or using them. Labels and checks describe what we saw at one commit and are not a guarantee. Read a skill's files before you run it. Terms of use