Content Delivery Network (CDN)
A Content Delivery Network (CDN) is a service that disperses your static assets to various server locations around the world. This makes static assets, which are generally large files like images, physically closer to users and therefore faster to download. As a CDN disperses assets across several server locations, the weight of your site is also distributed better during times of high traffic.
WP Engine’s CDN
CDN is included by default for all environments on Startup / Growth / Scale / Business+ hosting plans. Premium and Enterprise level plans include the first 1000 GB/Mo of CDN bandwidth.
Since static files are rarely updated or changed, CDN caches these files for 24 hours by default. You can purge cache for the CDN from the WP Engine plugin in the wp-admin area of your website.
For a full list of the available zones that the CDN uses, MaxCDN keeps an updated location listing here.
NOTE: CDN services are automatically enabled when using Cloudflare or GES. If we detect Cloudflare’s
cf-ray header in a request, we will not apply our CDN to your website. We recommend disabling WP Engine’s CDN if using Cloudflare. Check out our Cloudflare Best Practices for more information.
We advised enabling CDN for the first time during a lower traffic period because display may be broken while assets are picked up by the various zones. It can take up to 10 minutes for assets to be dispersed to the CDN zones.
We also advise adding an SSL on your domain first to ensure your CDN zone is generated securely and the assets are automatically loaded over SSL.
NOTE: If you are utilizing Cloudflare CDN or GES we do not recommend enabling WP Engine’s CDN. Read more here.
- Login to the User Portal
- Click Sites
- Select the production environment name
- Click CDN
- Check the box to the right of the domain
Similarly, if you wish to disable the WP Engine CDN, simply uncheck the box and click “Save”.
NOTE: If you need canonical headers enabled on CDN URLS, reach out to our support team.
Enable SSL on CDN URLs
If the CDN needs to serve assets securely over HTTPS, SSL must first be enabled on the CDN zone.
To configure this correctly, we recommend adding an SSL to your domain before enabling CDN for the first time.
If you’ve already enabled the zone or are still not seeing it secured, reach out to WP Engine Support 24×7.
Find the CDN URL
Finding the CDN domain is an important step to configuring the CDN with certain plugins and services. There are two potential default CDN domains:
CDN zone string IDs are different for every environment. If you need to find the URL or zone ID for your site:
- After enabling CDN right-click or ctrl-click a page on your site and select View Page Source
- Search the source code for your site for a URL like the following example.
- Your Zone ID is the characters at the beginning of this path.
Custom CDN Domain
Using a custom CDN domain (EX:
static.yourdomain.com) is entirely possible, but it’s important to be aware of how you will be securing that custom domain before starting this configuration.
- Each SSL certificate needs to be installed manually by our Support team on the zone if you wish to serve HTTPS assets.
- There is no way to install updated certificates automatically, it must be done manually each renewal at this time.
- We advise using a third party SSL that is several years in length.
- Let’s Encrypt certificates are not supported on custom CDN domains due to the brief time these are valid.
- We have no way to track the expiration on the SSL for your zone, so you will want to reach out to us and have the SSL updated as soon as possible on renewal so there is no downtime on your zone.
In order to configure a custom CDN domain:
- Acquire an SSL for your custom domain
- Upload the matching key and SSL certificate files to
- At your DNS host, point your custom CDN domain to your “insecure” CDN zone using a CNAME record:
- Reach out to WP Engine Support to have your custom domain and SSL applied to the CDN zone
Content not loading over CDN
When you enable WP Engine’s CDN a script automatically rewrites your site’s assets to use the CDN URL. Due to this, troubleshooting for CDN display issues will fall into a few categories.
The first issue you may run into is that the CDN initially can take up to 10 minutes to collect and begin displaying all assets. Your website’s display could be broken during this period, but will typically correct itself in a few minutes. We recommend waiting the full 10 minutes after activation if you are seeing display issues.
Next, there are some circumstances when our script to rewrite assets to the CDN URL will not catch the URLs as normal. These include:
- The use of a minification or compression plugin, such as WP Rocket or Autoptimize. Be sure to check the settings for an area to fill in your CDN domain so it’s compressed properly.
- A hard-coded or direct URL inside a file. This is a link in a file that uses a full URL (EX:
http://yourdomain.com/image.gif) to a relative, path-only, URL (EX:
image.gif). We don’t search and replace within CSS files, so for our automatic rewrite to work properly asset paths in your code need to use relative URLs.
- Using Cloudflare CDN services, including GES, will overwrite WP Engine’s CDN. Cloudflare CDN services are considered more optimal due to serving assets at the DNS level. Your WP Engine CDN URL will work, however asset URLs will not be rewritten to that URL automatically. Learn more.
Excluding and Including Assets
Our system works only by including directories to be offloaded to CDN servers.
If you have static assets you’d like included and served from the CDN that are stored outside the wp-content folder, contact support and we’ll help configure this on the server.
If you need to exclude a directory from the CDN that is located within wp-content, then every other directory in wp-content will need to be manually configured to offload to CDN. Contact support so we can help you set this up.
If you need specific files or file types excluded from the CDN, you’ll want to use an HTML post-processing rule to force it to load over your live domain instead. For example:
#https?://ZONEID-wpengine.netdna-ssl.com/(PATH-TO-FILE)# => https://DOMAIN.com/$1
Next Step: Configure Third-Party Email Hosting