12

I'm now setting myself to learn about AWS. Has anybody documented their experiences with CloudFront and Craft?

12

I'm running Amazon S3+CloudFront on several of my sites. There's not really much to it, Craft makes it really easy:

  • Create a new Amazon S3 assets source in Craft.
  • Set up CloudFront in AWS (see this link).
  • In the settings for your assets source, add your cloudfront url (something like http://xxxxxxxxx.cloudfront.net/, or your custom CNAME if you set one up) to the "URL Prefix" field.

That should be it!

  • Is this using CloudFront for just the assets, or for the entire site? When I attempt to use CloudFront for the entire site, I end up setting 'siteUrl' => '/' in my config. Does that seem right? – Marion Newlevant May 21 '15 at 17:38
  • Some times I only use CF for external assets like js libraries etc. Then I just set a new config item called 'cndUrl' => "" and set that before anything in my templates like {{ cdnUrl }}. – naboovalley Oct 16 '15 at 6:33
  • Andre has it exactly right -- we run a large production Craft Pro site through CloudFront for all assets, and use the settings just as he describes. You then actually have two layers of caching going on, since CF is just a large edge-cache, and Craft lets you set the cache length within the S3/CF Asset settings. So just be aware of the TTL for both of those levels. – Neal Magee Dec 29 '15 at 15:43
  • It's probably worth noting that this pertains to Asset sources only, and not whole-site caching with CloudFront. – Matt Stein Jul 12 '16 at 19:51
0

We are using the twig filter like this.

| replace({'http://s3-us-west-2.amazonaws.com/cranberrynm':'http://d15jwbqszojdqk.cloudfront.net'}) }}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.