简体   繁体   English

如何在 AWS CloudFront 中配置查询参数

[英]How to configure Query Params in AWS CloudFront

I have an AWS cloudfront ahead of an S3 bucket that contains my frontend app ( https://myapp.com ).我在包含我的前端应用程序 ( https://myapp.com ) 的 S3 存储桶之前有一个 AWS 云前端。 When I go to https://myapp.com/experts?profession=carpenter through the navigation elements of my site (button in this case) everything works fine.当我通过我网站的导航元素(在本例中为按钮)访问https://myapp.com/experts?profession=carpenter ,一切正常。 But when I try to access this same url by manually entering the url from the navigation bar of the browser the problem appears.但是,当我尝试通过从浏览器的导航栏中手动输入 url 来访问相同的 url 时,就会出现问题。 The query params disappear and only in the navigation bar is the following url without the query params https://myapp.com.com/experts .查询参数消失,只有在导航栏中是以下网址,没有查询参数https://myapp.com.com/experts

My question is, how should I configure AWS cloudfront to allow me to pass query parameters?我的问题是,我应该如何配置 AWS cloudfront 以允许我传递查询参数?

Many thanks!非常感谢!

For web distributions, you can choose whether you want CloudFront to forward query strings to your origin and, if so, whether to cache your content based on all parameters or on selected parameters. 对于Web分发,您可以选择是否要CloudFront将查询字符串转发到源,如果是,则选择是否基于所有参数还是基于选定参数来缓存内容。

By default, Cloudfront does not forward query strings, to improve the cache hit rate. 默认情况下,Cloudfront不转发查询字符串,以提高缓存命中率。

You can change that parameters in the behaviour definition, as per screenshot below. 您可以按照下面的屏幕快照在行为定义中更改该参数。

截图

https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/QueryStringParameters.html https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/QueryStringParameters.html

Now AWS has a different way to setup this, which is selected by default.现在 AWS 有一种不同的方法来设置它,默认情况下选择它。 The method Sébastien has mentioned in his answer is marked as "Legacy cache settings" Sébastien 在他的回答中提到的方法被标记为“传统缓存设置”

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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