How to use RocketCDN?

RocketCDN is WP Rocket's custom content delivery network. It is an optional, paid subscription service. Using a CDN will help improve the loading time of your website for visitors that are far away from where your server is located.

You can subscribe to the service directly from the CDN tab in WP Rocket:

When you subscribe to RocketCDN, we'll do the following: 

  1. Automatically create your unique rocketcdn.me CNAME - we do not offer customized CNAMEs, e.g. cdn.yourdomain.com (please check the FAQ section below).
  2. Automatically configure optimal performance settings for assets served from the CDN:
  • Apply GZIP compression
  • Apply CORS headers for webfont compatibility
  • Set a cache-control browser cache header
  • Set canonical headers
  • Serve assets over HTTP/2

All images, JS and CSS files will automatically be served from your RocketCDN CNAME. It is not possible to use more than one CNAME with RocketCDN.

RocketCDN also provides these benefits: 

  • Unlimited bandwidth
    We reserve the right to disable your RocketCDN Url if we detect bandwidth overuse
  • All CDN files automatically served over HTTPS
  • SSL Traffic included
  • All Global PoPs (Points of Presence) included


When should I purge the CDN cache?

If you have made changes to any static files without changing the filename, e.g you've replaced an image using the same filename, you should purge the RocketCDN cache: 


Why isn't Rocket CDN available on local/staging?

RocketCDN requires a live website to work correctly so it's not available on local sites. 

The subscription is unique to your domain - so you cannot use the same RocketCDN subscription on multiple domains. Therefore RocketCDN will not be available on the staging version of your site.


Using RocketCDN in production/staging setup

Each individual RocketCDN subscription can only be used on a single domain. This can create issues when you sync a production site that has RocketCDN, to a staging site that doesn't have it.

The staging site will try to load assets from the CDN URL, but the assets will fail to load because CDN URL is assigned only to the production site domain, not the staging site domain.

To solve this issue on staging site, you can manually turn off RocketCDN by unchecking Enable Content Delivery Network checkbox in WP Rocket → CDN tab:

It is also possible to programmatically turn off RocketCDN on the staging site when you synchronize it with the production site, via PHP using our function:

update_rocket_option( 'cdn', 0 );

For example, this function can be used in combination with our other functions to clear the cache and preload the whole site using CRON job, as explained in the document How to clear cache via cron job:

<?php 
// Load WordPress.
require( 'wp-load.php' );

if ( ! function_exists( 'rocket_clean_domain' ) ) {
    return;
}

// Disable CDN option
update_rocket_option( 'cdn', 0 );

// Clear cache and preload (if enabled).
rocket_clean_domain();

// Clear minified CSS and JavaScript files.
rocket_clean_minify();
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.