Is there a way to add cache control in AWS S3

+2 votes
I have moved about more 10000 files to AWS S3 using s3cmd command. Is there a way to add cache control in S3 for all the images.

if my files are reside ( s3://bucket-name/images/ ). How do i proceed?
Apr 10, 2018 in Cloud Computing by code_ninja
• 6,300 points
8,616 views

2 answers to this question.

+1 vote

use of  current upstream master branch will help for sure. use this github repository: https://github.com/s3tools/s3cmd. Next refer this command for the solutions

./s3cmd --recursive modify --add-header="Cache-Control:max-age=86400" s3://yourbucket/

You can learn more from the AWS Training and Certification.

answered Apr 10, 2018 by hemant
• 5,790 points
0 votes

To adjust metadata such as cache-control on an object in S3 without having to re-upload it and without having to use any third party tools, you can do the following with the AWS CLI. It copies the object to itself while overriding the metadata with your chosen settings:

aws s3api copy-object --copy-source <bucket-name>/<file> --bucket <bucket-name> --key <file> --metadata-directive REPLACE --cache-control "max-age=3600"

Process this command in a find to do it on an existing set of files that already exists in the bucket as you mention:

find . -type f -exec aws s3api copy-object --copy-source <bucket-name>/{} --bucket <bucket-name> --key {} --metadata-directive REPLACE --cache-control "max-age=3600"

replace <bucket-name> with the name of your bucket

WARNING: this will overwrite all your existing metadata on the files such as acl, just add additional flags to the command e.g. --acl public-read to set what you need.

answered Sep 7, 2018 by eatcodesleeprepeat
• 4,710 points

Related Questions In Cloud Computing

0 votes
1 answer

Is there a way to find out the number of objects stored in an S3 bucket?

Frankly, that is not possible. This is ...READ MORE

answered Apr 17, 2018 in Cloud Computing by code_ninja
• 6,300 points
808 views
0 votes
1 answer

Is there a way to transfer files between AWS s3 and ec2

The answer is a definite yes yes. ...READ MORE

answered Apr 17, 2018 in Cloud Computing by brat_1
• 7,200 points
797 views
0 votes
1 answer

AWS: Is there a way I can edit files in S3 right away in the browser?

There is not currently an AWS-supported method ...READ MORE

answered Jun 19, 2018 in Cloud Computing by Meci Matt
• 9,460 points
5,150 views
+1 vote
1 answer

How to add cache control in AWS S3?

Use modify command along with s3cmd  to ...READ MORE

answered Jul 25, 2018 in Cloud Computing by Gopalan
• 1,360 points
1,007 views
+3 votes
3 answers

Is there a way to install apache drill on an EMR cluster on AWS that is already Running?

It looks to be trying to get ...READ MORE

answered Oct 11, 2018 in Cloud Computing by findingbugs
• 4,780 points
2,329 views
0 votes
1 answer

Is there a way to test codes that are written against AWS API?

Please note that you should not integrate ...READ MORE

answered Apr 17, 2018 in Cloud Computing by brat_1
• 7,200 points
522 views
0 votes
2 answers

Is there a way to copy AMI from one AWS account to another AWS account using boto?

You could share the AMI from one ...READ MORE

answered Aug 21, 2018 in Cloud Computing by Priyaj
• 58,100 points
2,141 views
0 votes
1 answer

Is there a way to use amazon ECR image from one account in the code build of another account?

These forums might just help with AWS ...READ MORE

answered May 7, 2018 in Cloud Computing by brat_1
• 7,200 points
1,618 views
+3 votes
5 answers

AWS EFS vs EBS vs S3 (differences & when to use?)

EFS is: May not yet be available in ...READ MORE

answered Apr 9, 2018 in Cloud Computing by hemant
• 5,790 points
4,790 views
+1 vote
2 answers

I want to Migrate from Oracle RDBMS to AWS S3 using Kinesis

Try to understand AWS Schema Conversion Tool ...READ MORE

answered Apr 20, 2018 in Cloud Computing by hemant
• 5,790 points
2,399 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP