Database size increases with Remove Unused CSS

Remove Unused CSS stores some information in the database, and in some scenarios, it can grow quite large. 

There are two tables involved in database size issues when using Remove Unused CSS:

Used CSS table

Remove Unused CSS uses the  wpr_rucss_used_css table to store a hash to link the Used CSS to every cached page of your site. Note that while the hash is stored in the database, the actual Used CSS file is stored in the files. See this article if you're having disk space issues.

WP Rocket optimizes the database usage by using the hashes to share the Used CSS between pages that use identical CSS. However, this table can grow large if many cached pages have unique Used CSS values. 

Also, with the Mobile Cache feature, by default, an additional Used CSS is created for every page.

Solutions

The following are the possible solutions to address the problem in the Used CSS table:

Action Scheduler actions and logs tables

Sometimes, the Used CSS generation can get stuck in pending status in one of  Action Scheduler's tables called  wp_actionscheduler_actions.

WP Rocket runs an hourly cleanup for these entries. However, the presence of many stuck actions can fill up the database table with actions related to Remove Unused CSS, increasing the database size and also preventing Used CSS from being generated.

Solution

If the wp_actionscheduler_actions table is big, the solution is to delete the Remove Unused CSS rows.

Since this table is not used only by the WP Rocket plugin, you should not delete all its rows. We should delete only rows related to the Remove Unused CSS feature, identified by the  rocket_rucss_job_check_status hook.

If you're comfortable manipulating your WordPress database or running MySQL queries, you can use the following:

DELETE FROM `wp_actionscheduler_actions` WHERE `hook` = 'rocket_rucss_job_check_status' LIMIT 100;

Note: It's highly recommended to download a backup of your database. And it's recommended that your hosting support runs this query for you, taking all the necessary precautions.

The Action scheduler logs every step in actions' execution on a dedicated table called wp_actionscheduler_logs. Consequently, and if wp_actionscheduler_actions is causing you trouble, the wp_actionscheduler_logs will also have the exact same issue as well. 

Once actions related to Remove Unused CSS are deleted, you will need to run the following SQL command as well to clear all logs without a linked action to them.

DELETE log FROM wp_actionscheduler_logs log LEFT JOIN wp_actionscheduler_actions action ON log.action_id = action.action_id WHERE action.action_id IS NULL LIMIT 100;

Note: It's highly recommended to download a backup of your database. And it's recommended that your hosting support runs this query for you, taking all the necessary precautions.

If you have questions or need further assistance, you can contact support.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.