next.js
81114f36 - fix revalidation issue with route handlers (#63213)

Commit
2 years ago
fix revalidation issue with route handlers (#63213) ### What When a route handler uses an API that opts it into dynamic rendering (such as `no-store` on a fetch), and also specifies a `revalidate` time, the `revalidate` time is ignored and route is treated as fully static. ### Why `revalidate: 0` and `revalidate: false` have different semantic meanings: `false` essentially means cache forever, whereas `0` means it's dynamic. Since `0` is also falsey, the code we have to fallback with a default `revalidate` value for route handlers is incorrectly not marking the route as dynamic, and as a result, caching the route without an expiration time. ### How This updates the fallback handling for app routes respect a revalidation value of `0`, so that the page can properly be marked dynamic. ### Test Explanation This adds 2 new routes handlers: both have a revalidation time specified & use `no-store` on a fetch, but only one of them specifies `export const dynamic = 'force-static'`. The one that doesn't specify `force-static` is correctly omitted from the prerender manifest. The one that is `force-static` is correctly in the prerender manifest with the right expiration time. An additional test case was added to verify that this data refreshes after the specified interval. Closes NEXT-2764
Author
Committer
Parents
Loading