Amazon S3 和 Cloudfront 缓存,如何清除缓存或同步它们的缓存 [英] Amazon S3 and Cloudfront cache, how to clear cache or synchronize their cache

查看:147
本文介绍了Amazon S3 和 Cloudfront 缓存,如何清除缓存或同步它们的缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 cron 作业,它每 10 分钟运行一次并更新内容类型和 x-amz-meta.但是从昨天开始,似乎在 cron 作业运行之后,亚马逊没有接受所做的更改(刷新他的缓存).

I have a cron job that runs every 10 minutes and updates the content-type and x-amz-meta. But since yesterday it seems like after the cron job run, Amazon is not picking up the changes made (refreshing his cache).

我什至手动进行了更改,但没有更改...

I even went and made the changes manually but no change...

当视频上传时,它具有 application/x-mp4 内容类型,cron 作业将其更改为 video/mp4.

When a video is uploaded it has a application/x-mp4 content-type and the cron job changes it to video/mp4.

尽管 S3 具有正确的内容类型 video/mp4 cloudfront 显示 application/x-mp4(old content-type) ....

Although S3 has the right content type video/mp4 cloudfront shows application/x-mp4(old content-type) ....

cron 作业在过去 6 个月内一直正常工作,没有出现任何问题.

The cron job has been working for the last 6 months without a problem.

亚马逊缓存有什么问题?如何同步缓存?

What is wrong with amazon caching? How can i synchronize the caching?

推荐答案

使用 Invalidations 清除缓存,你可以把要清除的文件的路径,或者干脆用通配符清除一切.

Use Invalidations to clear the cache, you can put the path to the files you want to clear, or simply use wild cards to clear everything.

http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Invalidation.html#invalidating-objects-api

这也可以使用 API 来完成!http://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CreateInvalidation.html

This can also be done using the API! http://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CreateInvalidation.html

AWS PHP SDK 现在有这些方法,但如果你想使用更轻松的东西,请查看这个库:http://www.subchild.com/2010/09/17/amazon-cloudfront-php-invalidator/

The AWS PHP SDK now has the methods but if you want to use something lighter check out this library: http://www.subchild.com/2010/09/17/amazon-cloudfront-php-invalidator/

user3305600 的解决方案不起作用,因为将其设置为零相当于使用源缓存标头.

user3305600's solution doesn't work as setting it to zero is the equivalent of Using the Origin Cache Headers.

这篇关于Amazon S3 和 Cloudfront 缓存,如何清除缓存或同步它们的缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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