[英]Remove Cache-Control headers from AWS CloudFront?
I'm setting Cache-Control:s-maxage=3600 from my Origin server. 我正在从我的原始服务器设置Cache-Control:s-maxage = 3600。 By this I'm instructing my AWS CloudFront to cache the content for 3600 seconds. 由此,我指示我的AWS CloudFront将内容缓存3600秒。 I have white listed some cookies and set caching based on the cookie values in CloudFront. 我在白名单中列出了一些cookie,并根据CloudFront中的cookie值设置了缓存。 This setup is working fine until there is no proxy in between the client and my CloudFront. 直到客户端和我的CloudFront之间没有代理为止,此设置才能正常工作。
If there is Proxy, It also caches a version due to s-maxage header without considering the cookie value. 如果有代理,它还会由于s-maxage标头而缓存版本,而不考虑cookie值。 Due to this my end users are seeing irrelevant versions of my web page. 因此,我的最终用户看到了与我的网页无关的版本。
Is there any way to overcome this? 有什么办法可以克服这个问题? Or I need to write a Lambda@edge function to remove this Cache-Control:s-maxage=3600 in Viewer Response? 还是我需要编写Lambda @ edge函数以在“查看器响应”中删除此Cache-Control:s-maxage = 3600?
Create a Lamda@Edge function at Viewer Response and reset the Cache-Control header. 在查看器响应处创建一个Lamda @ Edge函数,并重置Cache-Control标头。
exports.handler = (event, context, callback) => {
/* Get response */
const response = event.Records[0].cf.response;
response.headers['cache-control'] = [{
key: 'cache-control', value: 'no-cache, no-store, must-revalidate'
}];
callback(null, response);
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.