如何在Amazon Cloudfront中设置Cache-Control Header? [英] How to set Cache-Control Header in amazon cloudfront?

查看:432
本文介绍了如何在Amazon Cloudfront中设置Cache-Control Header?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Amazon cloudfront发行版,为我的CDN创建了一个来源。在我的行为中,我设置了最大TTL,最小TTL和默认TTL。但是我的响应标头没有在重定向的静态文件中返回Cache-control标头。如何设置缓存控件?我需要这个来获取Google页面见解

I have a amazon cloudfront distribution that creates a 'origin' to my CDN. In my behavior, I set the Max TTL, Min TTL and default TTL. But my response header does't return the Cache-control header in my static files that are redirected. How to set the cache-control? I need this for the google page insights

用于创建缓存控制的文件

我的标头响应

推荐答案

您可以:
1.配置来源以添加响应中的Cache-Control标头。

2.使用Lambda @ edge(查看器响应,因为您只想将其用于Google页面见解)在响应中添加Cache-Control标头。
示例:
https: //github.com/jkrnak/serverless-lambda-at-edge/blob/master/handler.js

定义TTL不会添加任何缓存-control标头,它用于考虑需要缓存多长时间。

Defining TTL doesn't add any cache-control header, it uses to consider how long it need to cache.

这篇关于如何在Amazon Cloudfront中设置Cache-Control Header?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆