Disk Space Filling up Fast with LSCWP
LiteSpeed Cache for WordPress provides a number of optimization tools, like CSS Combine, or JavaScript Combine. When you use these tools, the goal is to make your pages load faster. Sometimes, though, these tools cause your disk space to grow very quickly, and that can be a problem. If this is happening to you, the reason is probably a randomized string in your CSS or JavaScript code.
The Problem With Randomized Strings
Why are random strings a problem? The presence of random strings causes a new combined file to be created for each page on your site. And if you’ve got a separate mobile view, then there will be two combined files created for each page in the site. For each additional cache vary on your site, another set of combined files will be created.
As you can imagine, this is not ideal, and it has the potential to fill up your server’s disk space very quickly.
To stop this behavior, you must exclude the randomized CSS or JavaScript from being combined. But first, you have to figure out where the random string is coming from.
Finding the Random String
To find a random string that is inline in your page’s HTML, here’s what you need to do:
- View the page without any optimization, in two different incognito browsers
- View the page source from each browser and compare them
- The only difference you should see is the random string itself. You can use that to determine which CSS or JavaScript should be excluded from optimization
An Example
Let’s go through an example:
- Open an incognito browser window and visit your site. Append the
?LSCWP_CTRL=before_optm
string to the end of the URL. Like this:https://example.com/?LSCWP_CTRL=before_optm
- Open another incognito browser window and visit your site without optimization, like this:
https://example.com/
- View the page source in each browser window.
- Copy and paste each source into a diff checker site like https://www.diffchecker.com/ and compare them.
- You should see just a few lines of CSS or JavaScript highlighted. This is where the two page loads differ, and it indicates where the random strings are.
- The strings should have a common part. (for example, if you see
abc_12345
andabc_67890
, the common part isabc_
) It will be something different for your own page, but it should be fairly easy to spot. - If the random string occurred in CSS, then navigate to Page Optimization > Tuning and enter the common part of the string into the CSS Excludes setting.
- If the random string occurred in JavaScript, then navigate to Page Optimization > JS Tuning and enter the common part of the string into the JS Excludes setting.
- Save your changes.
Finally, hover over the LiteSpeed icon on the WordPress Admin Bar and click Purge All in the drop down menu. This will clear the CSS and JavaScript page optimization files in the wp-content/litespeed
folder. After a short while the page optimization process will re-generate the files. Without any of the random strings, many fewer files will be generated, and you will see that it doesn’t take up much disk space at all.
Video
Prefer to see this topic in video form? Your wish is our command.
Conclusion
If you’ve tried these steps and are still having difficulty with your disk space filling up, your random strings may not be inline. They may be in combined CSS or JavaScript files. Here’s another method you can try to find random strings in combined CSS or JS files. If you’re still having trouble after that, open a ticket with our friendly support team, and they’ll be happy to help!
Comments