diff --git a/routes.js b/routes.js index d440c2f..daa7a26 100644 --- a/routes.js +++ b/routes.js @@ -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)