Skip to content

Display S3 image on Web - PHP application

0

We have a PHP web application where S3 images need be shown on the website. The page loads are slow as we are generating pre-signed URL for each image to show the image on the screen. Is there a better way to implement the use case to improve the page performance? the reason it is slow is the pre-signed URL takes time to generate and on the page load we are showing 100+ images.

  • The images are on a private bucket and not publicly accessible.

asked 2 years ago376 views

2 Answers
1

Understand you are loading 100+ images on a single page. Instead of loading actual images, you may want to generate thumbnails and load them instead. Since these are not actual images, you can make them public.

The tutorial Tutorial: Using an Amazon S3 trigger to create thumbnail images may help.

Another option is to front S3 bucket with CloudFront for private viewing. Instead of a S3 signed URL for each image, you can generate signed cookies for the entire site. So this will be one instead of 100+ API calls.

Refer to Serving Private Content Through Amazon CloudFront Using Signed Cookies and Serve private content with signed URLs and signed cookies for more information.

Since it supports multiple origins, you can also front both your website and S3 bucket with CloudFront. Besides the performance improvement from using a CDN, this configuration makes it easier to set CloudFront cookie.

AWS
EXPERT

answered 2 years ago

EXPERT

reviewed 2 years ago

0

Agree with Mike. Front the bucket with cloudfront with s3 as the origin

EXPERT

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.