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.
By default, assets are cached 24 hours on MaxCDN’s servers. You can purge caches for the CDN from the WP Engine plugin in the wp-admin area of your website.
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 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
NOTE: If you need your new CDN zone secured with an SSL, contact Support.
Finding 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.
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
Content not loading over CDN
When you enable CDN through your User Portal, a script automatically rewrites your site’s assets to use the CDN URL once activated. However, there are some circumstances when our script will not catch the URLs as normal. These can 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 direct URL inside a CSS 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 OR image.gif). We don’t search and replace within CSS files, so for our automatic rewrite to work properly asset paths in your CSS code need to use relative URLs.
Which files are loaded from CDN by default?
How long are CDN assets cached?
- Since static files are rarely updated or changed, CDN caches these files for 24 hours by default.
How do I purge CDN cache?
- CDN cache can be purged by using the “Purge All Caches” button within the WordPress Admin Dashboard, under the WP Engine tab.
What if I use an uploads directory that isn’t within wp-content?
- If you have static assets you’d like served from the CDN that are stored outside the wp-content folder, contact support and we’ll help configure this on the server.
Where are the CDN zones located?
- MaxCDN keeps an updated location listing here.
What if I need a specific file or file type excluded from CDN?
- You’ll need 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
What if I need a directory within wp-content excluded from CDN?
- Our system works only by including directories. Meaning every other directory in wp-content will need to be manually configured to offload to CDN. Contact support so we can help set this up.
I’m using the default CDN URL but it’s not loading securely over HTTPS.
- The SSL may have not activated properly. Contact support and we can get the SSL manually enabled.
What if I’m using Cloudflare CDN?
- We don’t recommend using multiple CDNs at the same time. If you prefer to use Cloudflare CDN you must disable our CDN. Check out our Cloudflare Best Practices.
Can I have canonical headers enabled on the CDN zone?
- Yes! Reach out to our support team to have those enabled.
How much does WP Engine CDN cost?
- Startup / Growth / Scale / Business+ — CDN is included by default for all environments
- Premium / Enterprise — First 1000GB/mo included