NuxtHub Cache automatically configures Nitro's cache storage. It allows you to cache API routes, server functions, and pages in your application.
Enable cache storage in your project by setting cache: true in the NuxtHub config.
export default defineNuxtConfig({
hub: {
cache: true
}
})
NuxtHub automatically configures the cache storage driver based on your hosting provider.
When deploying to Vercel, it automatically configures Vercel Runtime Cache.
No configuration is necessary to enable the Vercel Runtime Cache.
When deploying to Cloudflare, it automatically configures Cloudflare Workers KV.
Add a CACHE binding to a Cloudflare Workers KV namespace in your wrangler.jsonc config.
{
"$schema": "node_modules/wrangler/config-schema.json",
// ...
"kv_namespaces": [
{
"binding": "CACHE",
"id": "<id>"
}
]
}
Learn more about adding bindings on Cloudflare's documentation.
When deploying to other providers, it automatically configures the filesystem.
You can use any unstorage driver by providing a configuration object to cache.
export default defineNuxtConfig({
hub: {
cache: {
driver: 'redis',
url: 'redis://localhost:6379'
}
}
})