Skip to content
Dashboard

Introducing the Runtime Cache API

import { getCache } from "@vercel/functions";
export async function GET(request) {
const cache = getCache();
const cacheKey = 'blog';
const value = await cache.get(cacheKey);
if (value) {
return value;
}
const res = await fetch("https://api.vercel.app/blog");
const originValue = await res.json();
await cache.set(cacheKey, originValue, {
ttl: 3600,
tags: ['blogs'],
});
return originValue;
}

Ready to deploy?