Originally published at: Checking if the Removed Unused CSS feature in WP Rocket is Causing Performance Issues - MainWP WordPress Management
The WP Rocket is a well-used full-page caching plugin that includes a number of optimization options. In version 3.9 of the WP Rocket plugin, it included a new remove unused CSS beta feature. The feature will use a background process that will run from a cron event and can take a while to run the…
Looking in this closed WP Rocket GitHub repo issue shows that the RUCSS feature can cause high CPU usage on the site’s server and looks like it is still an issue in the most current version which is 3.9.2.
opened 07:59PM - 18 Jun 21 UTC
closed 12:44PM - 12 Apr 22 UTC
type: bug
priority: high
severity: major
module: remove unused css
**Describe the bug**
We’re getting some reports about high CPU usage with RUCSS… enabled, notably on Kinsta/WP Engine, and both pointing to the asynchonous process of the resource fetcher.
As a reminder, this process is triggered asynchronously on rocket_buffer, so running on uncached pages during the caching process. the AJAX action is `rocket_saas_warmup`
From their logs, some of those calls are running for too long, up to 6 min.
Looking at the code, during this call, we are:
- parsing the HTML for CSS/JS files
- for each file, we are getting the URL, path, content, type (and media value for CSS)
- For the content itself, we are getting it from the local file, or from the remote file if it’s an external path, and then we are Minifying it
- We finally send those to the background process which sends to warmup
-
I believe what would be causing the issue here is the content fetching + minifying step. Depending on the number of files found, it means a loop with a lot of processing in it.
I’m thinking this specific part should be delegated to the background processing task instead, as it can be running for longer in the background, and it has time and memory limit control.
We can investigate how to move `get_url_details()` from this class to the background processing class.
**Expected behavior**
No high CPU usage during this process
**Screenshots**
![image003](https://user-images.githubusercontent.com/3465180/122610747-2616ff80-d04e-11eb-8b3f-1a551ad3aa61.png)
**Backlog Grooming (for WP Media dev team use only)**
- [x] Reproduce the problem
- [x] Identify the root cause
- [x] Scope a solution
- [x] Estimate the effort
system
(system)
Closed
October 16, 2021, 4:39pm
4
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.