3

I'm developing a site with nuxt and hosting it on vercel. Doing performance tests with lighthouse, locally (always on the builds), I have no particular problems, while on the real site, there is always the problem: "Page prevented back/forward cache restoration". Now I'm trying them all, for example, I set this up in the vercel.json file:

{
   "routes": [
     {
       "source": "/",
       "headers": [
         {
           "Cache-Control": "no-store"
         }
       ]
     }
   ]
}

or this in the nuxt.config.ts file:

export default defineNuxtConfig({
   routeRules: {
     "/blog/**": {
       swr: 60 * 60,
       // or
       cache: {
         maxAge: 60*60
       }
     },
   }
});

and even this in the home script:

     window.addEventListener('load', function () {
       BroadcastChannel.prototype.postMessage = function () {
         throw new Error('BroadcastChannel cannot be used on cached pages.');
       };
     });

But nothing ever changes. What can I try?

Here is the full picture of the error: cacheError

Teo7
  • 47
  • 5
  • There are some [best practices](https://web.dev/bfcache/) that you should follow to avoid this issue – Duannx Jun 07 '23 at 01:22

0 Answers0