Try Nuxt ISR

This commit is contained in:
Sam Carlton 2021-09-04 16:48:53 -05:00
parent 7165f4db3c
commit 39a8a67f2f

View file

@ -8,4 +8,19 @@ module.exports = new Router()
.match('/service-worker.js', ({ serviceWorker }) => {
serviceWorker('.nuxt/dist/client/service-worker.js')
})
// Nuxt ISR
// https://docs.layer0.co/guides/nuxt#section_incremental_static_rendering__isg_
.get('/app/:id', ({ cache }) => {
cache({
edge: {
// Requests for product pages that are not statically generated will fall back to SSR.
// The first user will see the 200.html loading page generated by Nuxt.
// Layer0 will render full HTML response in the background and cache it for one hour at the edge.
// All future requests to the page will result in the full HTML response.
maxAgeSeconds: 60 * 60 * 24,
staleWhileRevalidateSeconds: 60 * 60, // continue to serve stale responses from the edge cache while refreshing via SSR in the background
},
})
})
.use(nuxtRoutes)