最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

javascript - How to change TTL when using swr in Nuxt 3? (per-route preferably) - Stack Overflow

matteradmin6PV0评论

The Nuxt 3 documentations says that swr enables a static build, that lasts for a configurable TTL, however, nowhere was I able to find how exactly one would change the TTL & whether it can be set per-route. Is that possible? If so, how?

I've looked at github & also tried to find it in Vite / Nitro documentation but didn't find anything.

I found something about image TTL in Nitro config source files but I suppose that's not what I was looking for.

The Nuxt 3 documentations says that swr enables a static build, that lasts for a configurable TTL, however, nowhere was I able to find how exactly one would change the TTL & whether it can be set per-route. Is that possible? If so, how?

I've looked at github & also tried to find it in Vite / Nitro documentation but didn't find anything.

I found something about image TTL in Nitro config source files but I suppose that's not what I was looking for.

Share Improve this question edited Dec 7, 2022 at 7:47 Matej asked Dec 7, 2022 at 7:46 MatejMatej 2717 silver badges24 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

After some investigation & experimenting, I found out that it is possible to adjust the TTL already! You just set it to an integer value instead of a boolean.

export default defineNuxtConfig({
    routeRules: {
        '/**': { swr: 5  }, // 
Post a comment

comment list (0)

  1. No comments so far