Browsers not caching images from s3

0 votes

I'm hosting my personal portfolio on AWS Elastic Beanstalk, using s3 to store all the data, such as images, entries etc. This uses Django for the backend, and Reactjs for the frontend.

When loading the content, the browser makes a request which gets these datapoints

const getAllNodes = () => {
    fetch("./api/my-data?format=json")
        .then(response => response.json())
        .then((data) => {
            setMyData(data);
        });
};

The returned values are the file image urls, something along the lines of

https://elasticbeanstalk-us-east-1-000000000000.s3.amazonaws.com/api/media/me/pic.png

with the following options

?X-Amz-Algorithm=XXXX-XXXX-XXXXXX
&X-Amz-Credential=XXXXXXXXXXXXXXXXXXXXus-east-1%2Fs3%2Faws4_request
&X-Amz-Date=20230102T182512Z
&X-Amz-Expires=600
&X-Amz-SignedHeaders=host
&X-Amz-Signature=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

When using this method of image storage and retreival, the images don't seem to be cached on the browser, so they have to be fetched every time, and slow down the site's functioning on subsequent visits.

The following is a screenshot of the network tab when loading my site. Note how the images aren't cached

images not being loaded from cache

How should I handle this situation? I would like to store the images in the database (and therefore on s3) so I can update them as necessary, but also have the advantage of having them be cached

Jan 3, 2023 in AWS by Tejashwini
• 3,820 points
503 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In AWS

0 votes
1 answer

Upload images from local machine to Amazon S3

There's a nice example in the aws-mobile-react-native-starter repo.  You just ...READ MORE

answered Jan 16, 2019 in AWS by disha
2,562 views
0 votes
1 answer
+1 vote
2 answers
+1 vote
4 answers

How do I cache my images which are stored in Amazon S3?

when caching ec2 instance these can be ...READ MORE

answered Oct 23, 2018 in AWS by Nabarupa
9,125 views
+1 vote
2 answers

Want my AWS s3 Bucket to read Name from CloudWatch Event

CloudTrail events for S3 bucket level operations ...READ MORE

answered May 28, 2018 in AWS by Cloud gunner
• 4,670 points
2,078 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
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