简体   繁体   中英

CloudFront strange behavior

I spent a few hours on a AWS CloudFront problem, hope someone can save me :D

When i load the site homepage, for every assets i get (on each reload):

X-Cache:Miss from cloudfront

When i try to open an asset in another tab, i then got the correct behavior (miss on first call, then hit on each reload). Same with curl requests.

I reload my home and inspect the same asset, i get:

X-Cache:Hit from cloudfront

with a similar age as in the tab.

Then i reload my homepage and inspect the same element again:

X-Cache:Miss from cloudfront

:'(

And from this point, when i reload the asset in the other tab, i get a miss...

Any idea ?

Thanks,

Jérémy

After many tests on Apache configuration and CloudFront configuration, i found that cookies where causing this behavior.

Some cookies used by tracking systems change their values on each call and then cloudfront do not cache the request.

To solve it, create a custom behavior for each type of path (backend calls, assets, etc.) and create a whitelist of cookies that you really need to forward in it.

i hope this will help someone.

Thanks @AlexZakharenko and @BruceP for your replies ;)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM