简体   繁体   English

如何为相同内容类型的所有S3对象添加缓存控制标头?

[英]How to add cache-control header for all S3 objects of a same content type?

For a S3 bucket, I want my all .jpg objects from Cloudfront (ie '.jpg' objects having Cloudfront URL) get served from disk / memory cache. 对于S3存储桶,我希望从磁盘/内存缓存中获取来自Cloudfront的所有.jpg对象(即具有Cloudfront URL的'.jpg'对象)。

I can't go with the way of adding cache-control header or expires header in S3 object's properties - metadata by visiting each of them, because I have more than 100k .jpg files in whole bucket. 我无法通过在每个S3对象的属性中添加缓存控制标头或使标头过期的方式来访问元数据,因为我在整个存储桶中有超过100k个.jpg文件。

To add this cache control header to all objects - one of my colleagues had ran some script by S3 browser and due to this file type has changed to 'binary/octet-stream'. 为了将此缓存控制标头添加到所有对象,我的一位同事已通过S3浏览器运行了一些脚本,并且由于此文件类型已更改为“二进制/八位字节流”。 The script/command he ran I guess it's something like- 他运行的脚本/命令我想这就像-

./s3cmd --recursive modify --add-header="Cache-Control:public ,max-age= 31536000" s3://your_bucket_name/

So, now I want to avoid these incorrect changes and with that also want to set caching for only '.jpg' objects/files and not all objects from bucket. 因此,现在我要避免这些不正确的更改,并且还希望仅针对“ .jpg”对象/文件而不是存储桶中的所有对象设置缓存。

How can I do that? 我怎样才能做到这一点? The server I am using is Litespeed and not Apache. 我使用的服务器是Litespeed,而不是Apache。

尝试在命令中添加--include "*.jpg" --exclude "*.*"

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

相关问题 从PHP AWS SDK设置S3对象的缓存控制HTTP标头 - Set Cache-Control HTTP Header for S3 Objects from PHP AWS SDK S3 / CloudFront,提供标题为“Cache-Control:max-age = 365000000,immutable”的所有文件 - S3/CloudFront, serve all files with header “Cache-Control: max-age=365000000, immutable” AWS Elastic Beanstalk / S3 / CloudFront缓存控制标头 - AWS Elastic Beanstalk / S3 / CloudFront Cache-Control Header 给定S3路径以及有效的密钥和机密,如何更新对象缓存控制标头? - Given an S3 path and a valid key and secret, how do I update an objects cache-control headers? 向所有 S3 文件添加缓存控制和过期标头但防止它们变得不可访问的正确方法? - Correct way to add cache-control and expires headers to all S3 files but prevent them from becoming inaccessible? 使用CLI将对象与expires和缓存控制头同步到S3? - Sync objects to S3 with expires and cache-control headers using the CLI? 在 AWS Cloudfront 中如何添加缓存控制? - In AWS Cloudfront how to add cache-control? 未应用Amazon S3图像缓存控制 - Amazon S3 images cache-control not being applied 如何在 AWS S3 中添加缓存控制? - how to add cache control in AWS S3? 如何使用 CLI 删除 S3 中的 Cache-Control 元数据? - How can I remove Cache-Control metadata in S3 using the CLI?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM