Using WP Rocket with a CDN

The Content Delivery tab is generally compatible with most CDN providers, including Amazon Cloudfront, MaxCDN, KeyCDN and others. This article contains basic information about integrating different CDN services with WP Rocket, troubleshooting and other useful information.

If you need information about Cloudflare, please refer to the Using WP Rocket with Cloudflare article instead.

Forget configuration headaches, WP Rocket has its own premium CDN service, RocketCDN. Our automatic configuration provides the best speed results!

RocketCDN

RocketCDN is WP Rocket's own optimized CDN service. It comes in free and pro plans, and you can start using it from the Content Delivery tab:

start rocketcdn.

Default: “Pull” CDN

A “pull” CDN (or “pull zone”) will automatically import (“pull”) files from your WordPress site. 

To use WP Rocket with a “pull” CDN, go to the Content Delivery tab, click on Other CDN > ADD CNAME, and set the CNAME (domain) given to you by your CDN provider and enter it in CDN CNAME(S) box:

adding your cdn cname.

By using Content Delivery > Other CDN, WP Rocket will:

  • Rewrite all URLs for your assets (static files like images, CSS/JS files) that are present in the HTML of the page. 
  • Add a preconnect resource hint for your CDN CNAME, with a dns-prefetch as a fallback.

Heads up! If you see that a file is not being served from your CDN, it might be because it's being loaded from an AJAX request, or being dynamically inserted into the page after the HTML has already been generated.

Advanced: “Push” CDN

A “push” CDN (or “push zone”) does not import any files from your website by itself; instead your website must send (“push”) all required files to the CDN.

WP Rocket does not handle the push process itself. If you use a "push" CDN, you will need an extra plugin to send your assets.

Amazon Cloudfront

If you use Amazon Cloudfront as a “push” CDN, we recommend this plugin (plus the add-on for the other static files) to get your assets uploaded to Cloudfront automatically:

WP Offload Media Lite

Important: WP Offload Media Lite Rewrite Asset URLs option (found on Offload Media > Assets) will prevent WP Rocket from minifying CSS and minifying and combining JavaScript files. It needs to be turned off. 

Further reading on Cloudfront:

KeyCDN

KeyCDN have a tutorial for setting up WP Rocket with their service here:

Kinsta

Kinsta’s CDN is powered by Cloudflare therefore it will work automatically with WP Rocket.

Checking the “Content Delivery” option is not required.

WP Engine

If you are using WP Engine's Global Edge Security or advanced network, you should not use the WP Rocket > Content Delivery tab. Both services have the CDN at the DNS level.

Optimole

If your site is using Optimole for image optimization and delivery using their free CDN, you don't need to enable the WP Rocket > Content Delivery tab.

GoDaddy CDN

If your site is hosted at GoDaddy Managed WP and you are using their CDN service, you still have to go to WP Rocket > Content Delivery > Other CDN, and enter your CDN URL in our CNAME field (e.g. https://secureservercdn.net/166.62.107.20/wmr.xxx.myftpupload.com/) so our plugin can detect it and function correctly. If you’re not sure what your CNAME is, please contact your GoDaddy support.

Siteground CDN

Siteground's own CDN works at the domain level (like Cloudflare) so there is nothing you need to do in the WP Rocket > Content Delivery tab.

WPX CDN

WPX’s custom-build CDN is completely integrated with WP Rocket, so there is nothing you need to do in WP Rocket's Content Delivery tab.

CDN on SSL sites

If your site is SSL-enabled, i.e. it uses HTTPS, your CDN must also serve files via HTTPS. To check if your CDN is SSL-enabled, visit the HTTPS version of your CDN URL in your browser. If it is NOT SSL-enabled, you will see a security warning like the one below:

You have to contact your CDN provider to enable HTTPS for your account.

Troubleshooting

If you experience any other issues with your CDN setup in WP Rocket, you should first confirm this is the problematic feature. You can do this by temporarily deactivating this option and checking if the issue is resolved.

Once you've confirmed CDN rewriting is the problematic feature, please review the following tip and articles:

Exclude files from your CDN

If you're having issues with serving certain type of files from the CDN, you can exclude them like this:

  • JavaScript files: /(.*).js
  • CSS files: /(.*).css
  • Images: /(.*).jpg , /(.*).png, /(.*).webp or /(.*).svg
  • PDFs: /(.*).pdf

Articles

Technical notes

You can use the following filters and snippet to customize CDN rewrite as per your needs:

  • Filter to enable CDN rewrites on inline script tags:
    add_filter( 'rocket_cdn_exclude_inline_scripts', '__return_false' );

  • Filter to disable CDN rewrites on relative paths:
    add_filter( 'rocket_cdn_relative_paths', '__return_false' );

Please note: If you're using a custom media uploads directory, the wp_uploads_dir function is used to determine the correct path.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.