acordero
acordero

Reputation: 45

Cloudfront prevent caching whole site

I want use Cloudfront for caching jpg, png, css, js files from a Prestashop website (domain.com) and get a fastest website. I setup this configuration:

I create a distribution in Amazon CloudFront with origin domain.com and alternate domain name static.domain.com

Domain.com = Prestashop website static.domain.com -> CNAME -> xxx.cloudfront.net (Provided from CF)

Now, when i load "static.domain.com" load a WHOLE site "domain.com". This is bad for SEO and will be expensive caching whole site.

I want to optimize and configure correctly CF for:

  1. Catching only certain files
  2. Prevent unnecessary expenses

I try to configure behavior, but always load the whole site. Where can I configure the files to cache? Can someone help me please? Thanks u and regards

Upvotes: 0

Views: 1557

Answers (1)

Ervin Szilagyi
Ervin Szilagyi

Reputation: 16775

You can create additional Behaviours for your CloudFront distribution. On each behaviour you can set a path patterns, example: images/*.jpg. This means, that the behaviour will apply only to paths which requesting certain images from your origin.

Every CloudFront distribution has a default behaviour, which has the path patter of * (cache everything). You can disable that by setting the cache policy to: Managed - CachingDisabled (see: disable caching for certain files).

Upvotes: 2

Related Questions