-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conflict between service worker and CloudFront? #3082
Comments
I set the CloudFront TTLs (default, min, max) all to 0. There's still odd behavior going on. If I redeploy my updated app and then open it up, I see in the console a message telling me to refresh, that there's an update. I do so, and I see the code update, but the log says once again to refresh to get an update. That behavior seems wrong. Any insight on how to properly deploy to S3 + CloudFront would be really helpful! UPDATE: I think I got it. I've left CloudFront cache settings alone (using origin headers, etc), and changed my deployment to single out these two files now:
The service worker itself was getting cached, which is problematic. But someone let me know if there's a better way still. 😉 |
You are on right track. |
@ffxsam could you please verify these settings for my cloudfront |
@ffxsam do your users need to refresh their page or revisit their links for their cache to get updated? |
Hey guys, just wanted to reply and say that since my last post, I've started using Netlify for deployment. It's far easier than AWS's solutions for deployment & CDN, and offers more features. |
@ffxsam solution worked for me.
EDIT: as @lalzada pointed, this is just a solution for devs and/or known testers. Asking real users to clear their cache is not a good solution at all. |
@gaguirre based on your step 2, would you ask all of your users to clear browser cache after you deploy a new build? not sure if this is the solution... |
@lalzada I was working in a test version actually, so I had no real users actually. Thanks for your question, I'll edit my comment 👍 |
I'm deploying my React app to S3 behind a CloudFront distribution. With my particular process, I copy all the files to S3, and then copy
index.html
in the following manner:The
Cache-Control
used to just bemax-age=0
, but I ran into problems with aggressive caching and added more options. I never wantindex.html
to be cached, otherwise when I release updates, users would still get the oldindex.html
pointing to the old JS files.Now I'm wondering if the service worker is somehow getting in the way. Should I remove it since I'm using CloudFront? Or is there a better way than what I'm doing to make sure that when I deploy a code update, that users will get it next time they reload or hit the site?
Thanks.
The text was updated successfully, but these errors were encountered: