How to Automate Large E-commerce Caching Without “Breaking” the Server: A PR22A Case Study
The Hidden Enemy of Speed
In the furniture industry, stock levels and prices change constantly. However, when managing thousands of products, manual cache clearing becomes impossible, while automated clearing often leads to server overloads. In this article, we’ll show you how we optimized this process for a client using LiteSpeed Cache, WP-CLI, and a bit of “server magic.”
The Problem: Load Spikes and 100% CPU Usage
Frequent cache purging (every 2-3 hours) is a double-edged sword. On one hand, customers see real-time data. On the other, immediately after a purge, the server must regenerate thousands of pages simultaneously. For our client, this resulted in:
100% CPU Usage, significantly slowing down the site for actual shoppers.
Timeout Errors (cURL error 28), as the server struggled to process requests in time.
Interrupted Processes, leaving large portions of the site uncached.
The Solution: Smart Automation in 3 Steps
1. Utilizing PHP-CLI for “Clean” Execution
Instead of relying on the standard WordPress Cron, which depends on site visits, we configured a system cron job. The key was using the direct path to the server’s PHP-CLI to avoid CGI conflicts and ensure stable execution.
2. Prioritization with the nice Command
To prevent automated processes from interfering with customer sessions, we utilized the Linux command /usr/bin/nice -n 19. This instructs the server to execute the cache clearing with the lowest priority—only when there are available resources.
3. Time Offsetting (The Staggered Approach)
One of the biggest mistakes is starting the purge and the “warming up” (Crawler) at the same time. We configured them with a strategic overlap:
00:00: Full cache purge.
00:20: Crawler start (initiating once the server has stabilized).
The Result: A Scalable Solution
After fine-tuning the Crawl Intervals and increasing the Server Load Limit, we achieved:
Green Zone resource usage (CPU maintained below 60%).
100% Automation – no manual intervention required.
Lightning-fast speeds for every user thanks to a pre-warmed cache.
Technical Cheat Sheet (The Final Formula)
For those looking to implement this immediately, here is the working cron job configuration for cPanel:
Cache Purge (Every 3 hours): 0 */3 * * * /usr/bin/nice -n 19 /opt/cpanel/ea-php83/root/usr/bin/php -d memory_limit=256M /usr/local/bin/wp litespeed-purge all --path=/home/user/public_html --allow-root >> /home/user/lscache_log.txt 2>&1
Crawler Start (20 minutes later): 20 */3 * * * /usr/bin/nice -n 19 /opt/cpanel/ea-php83/root/usr/bin/php /usr/local/bin/wp litespeed-crawler run --path=/home/user/public_html --allow-root >/dev/null 2>&1
Does Your Store Need “Smart” Caching?
If you answer “YES” to more than two of these questions, you are likely losing sales due to technical inefficiencies:
Do you update products frequently? (Prices, stock, new fabric models)
Do you notice slow page loading immediately after manual cache clearing?
Does your site contain over 500 unique URLs? (Products, categories, filters)
Have you ever seen a “508 Resource Limit Reached” error in your hosting panel?
Do you have a high Bounce Rate in categories with many products?
Technology at the Service of Business
Optimizing an e-commerce store doesn’t end with design and a working cart. It’s what happens “under the hood”—the correct communication between software and server. At PR22A, we believe automation is the key to scaling. When cron jobs are configured correctly, you don’t just save time—you guarantee your customers a seamless shopping experience and ensure your server has the resources to handle every request.
If you are having a problem with the speed of your WordPress site, fill out our form and we will contact you to review each case individually!