Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Amazon Cloudfront to serve images only

We use Amazon Cloudfront to host all our product images. We set up cloudfront so that cdn.mydomain.com will get the images from www.mydomain.com.

Recently, we have discovered that cdn.mydomain.com has been indexed with Google because when we type cdn.mydomain.com, Cloudfront serves full HTML version of our www version.

Is there anyway so that we allow Cloudfront to serve images only (jpg, gif, and png)?

Any suggestion would be welcome.

like image 982
user2719469 Avatar asked Oct 15 '25 13:10

user2719469


1 Answers

CloudFront provides a easy way to do this, in your distribution configuration go to the cache behaviors create a behavior that does only cache *.jpg

or if it is in images folder you can set rule to cache requests to that folder alone, its easy as that!

but definitely don't use rewrite rules! then there's no point in using cdn!!

like image 166
Karthick Selvam Avatar answered Oct 18 '25 08:10

Karthick Selvam



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!