amplify-hosting icon indicating copy to clipboard operation
amplify-hosting copied to clipboard

miss cloud front on browser

Open hokidoki opened this issue 3 years ago • 58 comments

Before opening, please confirm:

App Id

d2joh8jz57nkvq

Region

ap-northeast-2

Amplify Console feature

Performance

Describe the bug

Hello .

I installed Next.js following the AWS guide and hosted it on amplify.

However, every time I made a request to my service, the response was so slow. So, looking at the response header, the x-cache: Miss from cloudfront header is always present on browser. So I followed the instructions and enabled performance mode on my brunch in amplify but I'm still having the same problem.

The curious thing is that if you look at the x-cache header with the curl command, it was hit.

curl -X HEAD -i https://v.place.hitit.xyz/store/80e0a902-490f-4d96-b18d-988c852b2975 -s | grep -Fi x-cache x-cache: Hit from cloudfront

I suspect this is region related. Could you please check this as well ?

lambdaEdge : us-east-1 lambda : us-east-1 s3 : us-east-1 amplify : ap-northeast-2

Expected behavior

I don't have any customHttp.yml . it was problem ?

Reproduction steps

just enter my website.

https://v.place.hitit.xyz/ https://v.place.hitit.xyz/store/80e0a902-490f-4d96-b18d-988c852b2975

Build Settings

No response

Additional information

No response

hokidoki avatar Feb 03 '22 06:02 hokidoki

Hi :wave:, thanks for opening! While we look into this...

If this issue is related to custom domains, be sure to check the custom domains troubleshooting guide to see if that helps. Also, there is a more general troubleshooting FAQ that may be helpful for other questions.

Lastly, please make sure you've specified the App ID and Region in the issue!

github-actions[bot] avatar Feb 03 '22 06:02 github-actions[bot]

Hello, this is a known issue and we are working on a permanent fix.

As a workaround, please disable caching in your SSR distribution (Go to Behaviors in the CloudFront console and set min/max TTL to 0 for all behaviors). This should resolve the issue until we have a permanent fix in place.

Narrator avatar Feb 03 '22 14:02 Narrator

@Narrator hello Narrator

it work .but It's not a good idea to manually set the TTL every time I deploy.

When I asked the support team, they said that TTL is set by default and there is no way I can change it before deployment. Does any way exist?

hokidoki avatar Feb 04 '22 01:02 hokidoki

@Narrator I tried the workaround you suggested but doesn't seem to work for me My app id is d3aaj2ksbpdnai, region ap-southeast-1 We use this script to test

while true; do curl -X HEAD -i https://truck.isuzu-tis.com/product/gxz -s | grep -Fi x-cache; sleep 2; done
x-cache: Miss from cloudfront

beam36 avatar Feb 15 '22 12:02 beam36

After turned on the performance mode, the script does return 'Hit' but when I look at the network tab in Chrome, I still see 'Miss'

beam36 avatar Feb 17 '22 13:02 beam36

@beam36, can you double check if you have "Disable cache" unchecked in Chrome Network tab

saadataz avatar Feb 18 '22 23:02 saadataz

@saadataz I don't disable cache. Screenshot attached Screen Shot 2022-02-19 at 5 37 16 PM

beam36 avatar Feb 19 '22 10:02 beam36

Thank you for confirming @beam36. We are actively working on fixing the issue.

saadataz avatar Feb 22 '22 00:02 saadataz

@saadataz So there is no workaround?

beam36 avatar Feb 23 '22 14:02 beam36

@Narrator @saadataz It's been almost 2 months. Is there any update? If there's no fix soon, we'll have to consider moving to another platform.

beam36 avatar Mar 26 '22 01:03 beam36

@beam36 This is still work in progress. We will update this thread as soon as the issue fixed.

saadataz avatar Apr 02 '22 05:04 saadataz

@saadataz Is this something you guys are still actively working on? No update at all?

beam36 avatar Jun 03 '22 01:06 beam36

We have deprioritized the fix for this issue, since it will be resolved when we release the next iteration of our SSR service.

oliver-leung avatar Jul 19 '22 21:07 oliver-leung

@oliver-leung Can you confirm if there's any workaround (the one mentioned above doesn't work for me)? And can you say if the next iteration is weeks, months, or years?

beam36 avatar Jul 21 '22 03:07 beam36

Unfortunately, we don't have a workaround, nor an estimated date by which it will be resolved.

oliver-leung avatar Jul 22 '22 16:07 oliver-leung

still not fixed ? I face same issue.

70ki8suda avatar Jan 07 '23 02:01 70ki8suda

@beam36 @70ki8suda @hokidoki We've since released our next iteration of our SSR provider - please follow the steps here to migrate your app: https://docs.aws.amazon.com/amplify/latest/userguide/update-app-nextjs-version.html

If you're still facing this issue, please let us know on this issue and we'll take another look!

oliver-leung avatar Jan 15 '23 21:01 oliver-leung

@oliver-leung Hi, I migrated my app(using Nextjs ver13) to web computing platform. (https://ver-13-production.d2471u3n4mcim4.amplifyapp.com ) When using performance mode, instant cache invalidation on deployment does not work and a cache from a previous deployment remains in Cloud Front and references an old non-existent static file, resulting in a bug that does not display properly. This does not happen in every browser. But if one browser picked up old CDN cache, it remains showing inappropriate display until CDN cache expires.

70ki8suda avatar May 19 '23 02:05 70ki8suda

Status? Been a while now....

ArmanNisch avatar Jun 01 '23 08:06 ArmanNisch

Hi team, we are also facing this issue. We have hosted our webpack built web application. The assets are always miss from cloudfront and the downloads are delayed because of that. Can you share some ETA on this fix?

MVMS1994 avatar Jun 07 '23 10:06 MVMS1994

I am having the same issue with a simple next.js ssr, ssg apps, gatsby apps. All requests come back with X-Cahce: Miss from cloudfront

This issue was opened more than 1.5 years ago. I would expect a solution by now

anatolzak avatar Jun 12 '23 03:06 anatolzak

I'm having the same problem. In the React CSR App environment, the requesting Asset is not doing Cache Hit. Because of this, there is a problem with the initial loading speed.

I think this is a big problem.

kkak10 avatar Jun 29 '23 20:06 kkak10

Are there any plans on fixing this issue? We will be forced to move away from AWS Amplify to a service that actually works

anatolzak avatar Jun 30 '23 12:06 anatolzak

is this still an issue?

adidoes avatar Sep 10 '23 17:09 adidoes

@adidoes yes, it's still an issue

anatolzak avatar Sep 11 '23 06:09 anatolzak

Just chiming in to confirm this is still an issue as of September 2023. We've been using AWS for a while but are new to Amplify. We're evaluating it as an alternative to Cloudflare Pages or Netlify, so this performance bottleneck is concerning.

Piggybacking on earlier comments that pointed out discrepancies between script-based and browser-based cache tests, I dug in a bit. There are two hosting options in Amplify: "Managed Hosting" initiated via the AWS Console and "CloudfrontAndS3" via CLI. The former is great until you hit issues like this; the latter lets you control CloudFront and S3 settings directly.

My focused hypothesis is that "managed hosting" doesn't adequately ignore cookies. When running curl -I {url}, I get x-cache: Hit from cloudfront. Browser-based tests almost always return Miss. However, clearing cookies and reloading will yield a Hit, if the cache is propagated (otherwise when you clear cookies and try again it will).

Quick tip aside: If you're still getting cache Misses, double-check your cache-control headers. Enabling performance mode will set s-maxage=600, but you can also use settings like s-maxage=60, stale-while-revalidate=7200, stale-if-error=86400 for more nuanced control.

It seems like a straightforward fix for the AWS team—just adjust the cache or origin request policies for managed CloudFront distributions to ignore all cookies.

As for a potential workaround, you can go with the "CloudfrontAndS3" option. However, that's at the expense of added complexity and maintenance on your end.

I'll be keeping my eye on this issue. I'm not interested in the added complexity of "CloudfrontAndS3." I want the simplicity that comes with using the console, but also want effective caching and, as a result, better performance. Fingers crossed for a fix soon.

rubengommers avatar Sep 18 '23 11:09 rubengommers

+1

teamzz111 avatar Sep 28 '23 06:09 teamzz111

+1

airton avatar Oct 11 '23 20:10 airton

+1

cercao avatar Oct 11 '23 20:10 cercao

+1

Timfts avatar Oct 11 '23 20:10 Timfts