Answers.Body: <p>I wrote up an article that might be helpful for future-people looking for step by step instructions on setting this up: <a href="https://nystudio107.com/blog/using-aws-s3-buckets-cloudfront-distribution-with-craft-cms" rel="nofollow noreferrer">Setting Up AWS S3 Buckets + CloudFront CDN for your Assets</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-27T20:19:35.023Z
Answers.LastActivityDate: 2020-01-27T20:19:35.023Z
Answers.UserDisplayName: andrew.welch
Answers.Body: <p>We are using the twig filter like this.</p>
  
  <pre><code>| replace({'http://s3-us-west-2.amazonaws.com/cranberrynm':'http://d15jwbqszojdqk.cloudfront.net'}) }}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-05T19:15:29.600Z
Answers.LastActivityDate: 2015-11-05T19:15:29.600Z
Answers.UserDisplayName: David A McInnis
Answers.Body: <p>I'm running Amazon S3+CloudFront on several of my sites. There's not really much to it, Craft makes it really easy: </p>
  
  <ul>
  <li>Create a new Amazon S3 assets source in Craft.</li>
  <li>Set up CloudFront in AWS (<a href="http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/GettingStarted.html">see this link</a>).</li>
  <li>In the settings for your assets source, add your cloudfront url (something like <a href="http://xxxxxxxxx.cloudfront.net/">http://xxxxxxxxx.cloudfront.net/</a>, or your custom CNAME if you set one up) to the "URL Prefix" field.</li>
  </ul>
  
  <p>That should be it!</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-21T17:38:39.110Z
Answers.Text: 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?
Answers.UserDisplayName: Marion Newlevant
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-10-16T06:33:43.110Z
Answers.Text: 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 }}`.
Answers.UserDisplayName: naboovalley
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-07-12T19:51:02.220Z
Answers.Text: It's probably worth noting that this pertains to Asset sources only, and not whole-site caching with CloudFront.
Answers.UserDisplayName: Matt Stein
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-12-29T15:43:01.657Z
Answers.Text: 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.
Answers.UserDisplayName: Neal Magee
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-18T22:01:40.653Z
Answers.LastActivityDate: 2015-05-18T22:01:40.653Z
Answers.UserDisplayName: André Elvan
Body: <p>I'm now setting myself to learn about AWS. Has anybody documented their experiences with <a href="http://aws.amazon.com/cloudfront/">CloudFront</a> and Craft?</p>
  
Tags: <s3><deployment><aws>
Title: How to set up CloudFront for a Craft site
ThreadText: # How to set up CloudFront for a Craft site
  
  (Asked by: username_0 on 2015-05-18)
  
  I'm now setting myself to learn about AWS. Has anybody documented their experiences with [CloudFront](http://aws.amazon.com/cloudfront/) and Craft?
  
  **Tags:** s3, deployment, aws
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_3 on 2015-05-18. Score: 12 | Accepted answer
  
  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](http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/GettingStarted.html)).
  * 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!
  
  > **Comments:**
  > **username_0**: 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?  
  > **username_4**: 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 }}`.  
  > **username_6**: 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.  
  > **username_5**: It's probably worth noting that this pertains to Asset sources only, and not whole-site caching with CloudFront.  
  
  ---
  
  ### Answer by username_1 on 2020-01-27. Score: 3
  
  I wrote up an article that might be helpful for future-people looking for step by step instructions on setting this up: [Setting Up AWS S3 Buckets + CloudFront CDN for your Assets](https://nystudio107.com/blog/using-aws-s3-buckets-cloudfront-distribution-with-craft-cms)
  
  
  ---
  
  ### Answer by username_2 on 2015-11-05. Score: 0
  
  We are using the twig filter like this.
  
  ```
  | replace({'http://s3-us-west-2.amazonaws.com/cranberrynm':'http://d15jwbqszojdqk.cloudfront.net'}) }}
  
  ```
  
  
  ---
  
  