Skip to content

Use CachedEventHandler options in nitro routes config #442

Answered by Hebilicious
LouisHaftmann asked this question in Q&A
Discussion options

You must be logged in to vote

It is already possible to enable SWR by passing swr: true option in nitro routes config but you can't set maxAge or any other CachedEventHandler options.

Example usage:

// nitro.config.ts
import { defineNitroConfig } from 'nitropack'
export default defineNitroConfig({
  routes: {
    '/blog/**': { swr: true, maxAge: 60 }
  }
})

You can specify cache options in RouteRules https://nitro.unjs.io/guide/cache#route-rules

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Hebilicious
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants