Use code PERFMATTERS for an extra 10% off!
  1. Home
  2. Docs
  3. General
  4. How to enable CDN rewrite in WordPress

How to enable CDN rewrite in WordPress

The CDN rewrite option allows you to easily use third-party CDN providers on your WordPress site. Rewrite means that it will automatically change all of your assets’ URLs on the fly to use the CDN URL. This way, your assets will load from all of the global CDN POPs, instead of just your server.

A few popular CDN providers we recommend include:

If you’re using Cloudflare you don’t need to do anything in Perfmatters. Cloudflare is different than traditional CDN providers and sits between your site and the public internet. Traffic is automatically routed through Cloudflare, and it doesn’t require a custom CDN URL. Make sure to check out our documentation on recommended Cloudflare settings for the best performance.

Enable CDN rewrite

Follow the steps below to enable CDN rewriting of your URLs.

Step 1

Click into the Perfmatters plugin settings.

Perfmatters plugin settings
Perfmatters plugin settings

Step 2

Click on the “CDN” submenu.

Perfmatters CDN
Perfmatters CDN

Step 3

Toggle on “Enable CDN Rewrite.” Note: Make sure to first configure your CDN URL.

Enable CDN rewrite
Enable CDN rewrite

Step 4

Scroll down and click “Save Changes.”

Important: If you’re testing on a staging site, you’ll probably need to turn the CDN rewrite feature off temporarily as the CDN URL will only match your live site.

Troubleshooting

It’s not possible to rewrite background images stored in third-party stylesheets to the CDN since we don’t have access to those files (inline background images work fine). However, the theme or page builder you’re using should hopefully provide you with a way to do this. Elementor, for example, currently has an open issue regarding this. A temporary workaround for Elementor would be to use their “Replace URL” feature and update the background image URLs with the CDN URL versions.

Was this article helpful?

Related Articles