Skip to content

Latest commit

 

History

History
71 lines (43 loc) · 3.55 KB

File metadata and controls

71 lines (43 loc) · 3.55 KB
description Use edge networks to ensure the fastest delivery of content.

Edges

Depending on the driver you use, CDN content will be served directly from the source. i.e if you're using the local file system driver assets will be served directly from there, if you're using the AWS S3 driver then images will be served directly from the bucket.

The Image Transformation endpoints, however, require some processing and as a result will use the server to mutate the image and then serve it. Whislt some caching is in place to reduce load, this does put a strain on the server, additionally a user might be geographically distant from the server.

To address this, you can leverage CDN edges, i.e a CDN service which will cache your content and serve it from a geographically close data centre to the user requesting it, and if it;'s in the cache, the request won't hit the server at all, saving you resources.

Fundamentally, configuring this is the same regardless of the CDN you wish to use, but in these examples we'll assume AWS CloudFront.

Serving vs Processing

There are two distinct behaviours with regards the CDN URLs: serving and processing. Serving is simply serving the asset as is, byte-for-byte. Processsing is mutating an image asset (see Image Transformation) and serving the modified version, for example cropping.

As such, we'll need to configure an edge for each type individually as they will have different origins.

Configuring CloudFront

This short guide will explain how to configure two CloudFront distribution to serve both standard content and processed images.

Here we assume that we're using the Local Filesystem driver with default settings.

The Serving Distribution

This distribution will use the application's assets/uploads directory as its origin. Create a new distribution, configuring it however you desire, but pay attention to the following key properties:

Property Value
Origin Domain Name https://your-site.com
Origin Path assets/uploads

{% hint style="warning" %} You will likely be using the AWS S3 driver if yoiu're configuring CloudFront, so set the origin to be the S3 bucket. {% endhint %}

The Processing Distribution

This instance will use the application's cdn/* URLs as its origin. Create a new distribution, configuring it however you desire, but pay attention to the following key properties:

Property Value
Origin Domain Name https://your-site.com
Origin Path cdn

{% hint style="warning" %} Regardless of driver, you will use the above configurations. {% endhint %}

Configuring the application

Once you have your Edges set up, the application will need to know about them. Set these in Admin.

  1. Navigate to Settings › CDN
  2. Navigate to the Drivers tab
  3. Click Configure beside your desired driver
    1. Now is a good time to double check that the driver is enabled
  4. Go to the URLs tab
  5. Update the fields to use your newly created distributions
    1. There are two fields for serving, and two for processing - a secure and a non-secure version for each. We recommend using a secure URL for both values.
  6. Click Save Changes

Now URLs generated by the CDN functions will use the CloudFront distributions.