WpW: How to Set Up a CDN with LSCache

October 25th, 2017 by LSCache 24 Comments

Welcome to another installment of WordPress Wednesday!

Disclaimer: The information contained in this post is accurate for LSCWP v3.6.4. If you are using a newer version of the plugin, some details may have changed. Please refer to our documentation for the latest!

LiteSpeed Cache for WordPress has the ability to support your Content Delivery Network usage. This quick guide should explain how the different settings between your CDN and LiteSpeed relate to each other.

Cloudflare or QUIC.cloud

If you are a Cloudflare user, or a QUIC.cloud user, you should not follow the instructions for reverse-proxy CDNs below.

Make sure you have set up you Cloudflare or QUIC.cloud account from its respective dashboard. Once that’s done, you’re ready to tell LSCache about the CDN solution you’ve chosen. Switch over to your WordPress Dashboard and navigate to LiteSpeed Cache > CDN > CDN Settings. Follow the appropriate set of instructions.

Cloudflare

If you wish to manage Cloudflare through LSCache, set the following:

  • QUIC.cloud CDN: OFF
  • Use CDN Mapping: OFF, and leave all settings under it alone
  • Cloudflare API: ON, and fill in your Email Address, Global API Key, and Domain

You can also use Cloudflare without managing it through LSCache. If that is what you choose, just set Cloudflare API to OFF, and leave all settings under it alone. Cloudflare will work either way. This setup just determines where you prefer to do such tasks as purging your Cloudflare cache or turning on Development Mode.

QUIC.cloud

If you wish to use QUIC.cloud, then set the following on this page:

  • QUIC.cloud CDN: ON
  • Use CDN Mapping: OFF, and leave all settings under it alone
  • Cloudflare API: OFF, and leave all settings under it alone

You will also need a Domain Key. If you don’t already have one, learn more about that here.

Reverse-Proxy CDNs

CNAME setup in the CDN

For this guide, we’re going to assume you have already set up your CDN account, and added your site (let’s call it example.com) according to the CDN’s instructions.

Make sure that your CDN is configured to cache static files only. Dynamic content will be handled by LiteSpeed.

Your CDN configuration screen should have an area for adding a CNAME record. Look for it under DNS Editor or something along those lines.

The goal here is to set up a custom domain to be used only by the CDN. For example, cdn.example.com. Follow the CDN’s instructions for adding the CNAME record.

Once that is complete, and the domain is active, we’ll be ready to tell WordPress how to proceed.

LiteSpeed Cache CDN Settings

Now that your CDN is set up and your static content is ready to be served by the CDN, you will need to let WordPress know about it. You can do this through LiteSpeed Cache.

In your WordPress Dashboard, navigate to LiteSpeed Cache > CDN > CDN Settings.

Make sure both QUIC.cloud CDN and Cloudflare API are set to OFF.

  • Use CDN Mapping: ON.
  • CDN URL: http://cdn.example.com.
  • Original URLs: //example.com.

The remaining settings can be left as-is, unless you have a specific reason to change them. If you do want to adjust them, this documentation should help.

And that’s it! Once you save your changes, LiteSpeed Cache for WordPress will substitute the CDN URL for the Original URL in the static copies it saves of your dynamically-generated code, wherever appropriate.

Want to learn more about how all of this works? We’ve written about our CDN support in some depth before. You can check that out here.

Have some of your own ideas for future WordPress Wednesday topics? Leave us a comment!

Don’t forget to meet us back here next week for the next installment. In the meantime, here are a few other things you can do:


Categories:LSCache

Related Posts


Comments