Content Delivery Network (CDN)
IMPORTANT: Websites using Global Edge Security, advanced network, or Cloudflare for DNS cannot use the CDN offering in this article. Learn more here.
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
At WP Engine we utilize MaxCDN for our included CDN offering. Only static assets such as images, CSS and Javascript located within the wp-content directory are offloaded and served by the 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.
For a full list of the available zones that the CDN uses, MaxCDN keeps an updated location listing here.
CDN Cache
Since static files are rarely updated or changed, CDN caches these files for 24 hours by default.
You can purge the cache for CDN from the the User Portal > Caching page, under Clear network caches.
Enable CDN
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.
- Login to the User Portal
- Click Sites
- Select the production environment name
- Click CDN
- Check the box to the right of the domain
- Save
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.
If you are using a custom CDN URL, an SSL will need to be purchased third party and uploaded to your website’s _wpeprivate
directory using SFTP or SSH Gateway.
NOTE: Websites using Global Edge Security or advanced network use CDN at a DNS level instead and don’t require these CDN configuration steps. Learn more here.
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:
Insecure:
http://ZONEID.wpengine.netdna-cdn.com
Secure:
https://ZONEID-wpengine.netdna-ssl.com
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.
NOTE: Struggling with complicated CDN domains? Websites using Global Edge Security or advanced network use CDN at a DNS level instead and don’t need a CDN URL. Learn more here.
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
_wpeprivate
using SFTP - At your DNS host, point your custom CDN domain to your “insecure” CDN zone using a CNAME record:
http://ZONEID.wpengine.netdna-cdn.com
- Reach out to WP Engine Support to have your custom domain and SSL applied to the CDN zone
NOTE: Don’t want the fuss of a custom CDN domain? Websites using Global Edge Security or advanced network use CDN at a DNS level instead and don’t need a CDN domain. Learn more here.
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
ORimage.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. - JavaScript which calls back to the server or references assets on the server, especially if AJAX is producing new HTML. The server can’t see into the JavaScript process, and we can’t post-process AJAX requests.
- 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
By default, we serve all the static assets (images, JavaScript, CSS) located in your wp-content folder from CDN. This includes thumbnail-generation systems and minified files. WordPress core files are also served from CDN.
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
NOTE: Struggling to get your assets to show the CDN URL? Websites using Global Edge Security or advanced network use CDN at a DNS level instead and don’t use a specific URL. Learn more here.
CDN Overages
MaxCDN is included on all shared environment plans with no bandwidth overage costs.
Premium and larger accounts include the first 1000GB/mo free with a $0.12/GB/mo bandwidth overage cost.
As a MaxCDN alternative, the advanced network and Global Edge Security both include Cloudflare CDN at no additional cost.
NEXT STEP: Configure Third-Party Email Hosting