1. Home
  2. Hosting Management
  3. Website Speed
  4. How to Generate Unique CSS in LiteSpeed Cache for WordPress

How to Generate Unique CSS in LiteSpeed Cache for WordPress

You probably take a lot of pride in the appearance of your website. Maybe you’ve spent a lot of time (and/or money) on customizing your website to give it a unique look. Unless you’ve been working with the code directly, you may not know this, but your website’s appearance is owed to a series of CSS files that are loaded each time a page is requested by a client’s browser. What you also may not know is that not every page needs to load every style in the library, and server resources are often wasted parsing code that isn’t relevant to the requested page.

The new Unique CSS feature, now available in the LSCache for WordPress Plugin, allows users to discard this code and load only the necessary CSS to make the page display properly.

What is Unique CSS?

If you’ve ever examined the CSS files that are included with your chosen WordPress theme and plugins, you may have noticed — they’re very large. Why is this?

Well, they must contain every CSS definition for every variant of every page on your site.

Let’s say you open your site in your browser and are looking at your About page. If you open up the code, most of the code being loaded for that page isn’t relevant to the page. This means your browser has to request all this code, then sift through it and show only the relevant bits. This takes time, even for a super-fast PC on a lighting fast internet connection.

With Unique CSS, a separate and single CSS file is created for each page on your site, where the only defined styles used are the ones required to load the content on the page being requested, thus lowering the amount of code the browser has to sift through, therefore lowering the load time.

How to Enable Unique CSS in LiteSpeed Cache

Enabling Unique CSS is pretty easy, however, you do need a domain key from Quic.Cloud to use the Unique CSS feature of the plugin. Don’t worry, this is super easy to do and it doesn’t mean you need to change anything on your site or CDN.

Step 1: Login to your /wp-admin and in the menu on the left, hover over the LiteSpeed Cache option. Then, in the little menu that pops out, click General.

Step 2: When the General Settings page opens, look for the Domain Key Section.

Click Request Domain Key.

After clicking Request Domain Key, your page will reload and you will see this message at the top of the page:

If you wait about a minute, maybe two, then refresh the page again, you’ll note the Domain Key field is filled with ***. This means you have a domain key from Quic.Cloud!

Your domain key field will look like this when your key has been issued:

Step 3: Now, to enable Unique CSS, return to the menu on the left and look for LiteSpeed Cache > Page Optimization.

Step 4: Once the Page Optimization settings have loaded, look for the Generate UCSS option and click the On Setting.

Then click Save Changes in the top right corner.

Step 5: Now you need to enable Cache Mobile because CSS for mobile views is different than the desktop views. To do this, navigate to the Cache option in the LiteSpeed menu on the left.

Step 6: Once the Cache Settings page has opened, look for the Cache Mobile option. Click On to enable the feature, then click Save Changes in the top right corner.

Step 7: Now you need to Purge your existing Caches. To do this, hover over the LiteSpeed icon in the top menu and choose Purge All.

From this moment forward, anytime someone visits your site, the Unique CSS for that page will be served. If the UCSS hasn’t been calculated, it will be added to a queue to be generated via Cron later on.

Congrats!

Are you tired of slow WordPress hosting? We use LiteSpeed caching to deliver content to your visitors almost instantly.  Check out our WordPress Hosting plans

Updated on March 18, 2022

Was this article helpful?

Related Articles

Tired of struggling with troubleshooting? 🤔
If you enjoyed this article, you’ll love our support team even more! Get up to 65% off and a FREE Domain for a limited time. 👇
View Plans

Leave a Comment

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.