skip to Main Content

I have a react application deployed to AWS Amplify. However, every time I push a new feature to the pipeline, the feature will not appear on the live site right away. I understand that the build takes time but the problem persists even after Amplify notifies me that the build was completed. I believe it has to do with the browser cache, because opening up the site in an incognito tab works.

Therefore, does anyone know how to address the issue? I could not ask clients to clear their cache every time I made an update…

2

Answers


  1. You can add Cache-Control tag on your public/index.html

    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
    <meta http-equiv="Pragma" content="no-cache" />
    <meta http-equiv="Expires" content="0" />
    

    Example.

    <html lang="en">
      <head>
        <meta charset="utf-8" />
        <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
        <meta http-equiv="Pragma" content="no-cache" />
        <meta http-equiv="Expires" content="0" />
      </head>
      <body>
        <noscript>You need to enable JavaScript to run this app.</noscript>
        <div id="root"></div>
      </body>
    </html>
    
    Login or Signup to reply.
  2. you can also disable your broswer caches by inspect then go to your network tab and disable your caches then run npm run dev with flag --force to rebuild dependencies again and refresh your broswer

    more info can be found here in vite doc website https://vitejs.dev/guide/dep-pre-bundling.html#browser-cache

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search