WP-Optimize plugin is one of the top ones for optimizing website loading speed and image size. However, sometimes you may encounter an unpleasant error in the plugin’s operation: the cache folder becomes huge within a short time and does not clear automatically. We will tell you how to act in this situation.
WP-Optimize cache folder issue
You can notice a significant increase in the cache folder on your own, or, more likely, you will receive an email from your hosting provider with the subject “Notification of exceeding the disk space quota by hosting account XXX” and the text of such a plan: “Your hosting account XXX has used more than 95% of disk space. ” Immediately, we note that such a message is not a reason to panic, since you can always switch to a more loyal WordPress hosting (hosting review) or simply delete the cache folder.
As a reminder, your site’s cache folder is accessible via FTP and located at /wp-content/cache.
However, deleting the WordPress cache folder is only a temporary solution, since the plugin will continue to create a cache and soon the disk will be full again. What to do?
Setting cache lifespan in WP-Optimize plugin
You can change the storage time and, accordingly, clear the cache in WP-Optimize by following the links in the dashboard:
- /wp-admin/admin.php?page=wpo_cache – In the Cache settings block, set a lower value for the Cache lifespan, for example, 1 day.
- /wp-admin/admin.php?page=wpo_minify&tab=wp_optimize_advanced – In the Advanced options block, set a lower value for the Cache lifespan, for example, 1 day.
After 1-2 days, you need to check that the cache is actually cleared. If everything is correct, then the problem is solved. Congratulations!
However, in some cases, automatically clearing the cache using the plugin does not work. We described a similar situation in the article “WP Rocket cache folder has become huge. What to do?”. Then we solved the issue by simply disabling the incorrectly working function, but now we will solve the issue differently.
Adding the Cron event to clear WP-Optimize cache
To add a new Cron event, you need to install and activate the WP Crontrol plugin.
Next, go to the plugin settings at: /wp-admin/tools.php?page=crontrol_admin_manage_page.
Add a new Cron event by clicking the button at the top Add New.
On the page that opens, select the Event Type PHP cron event and add the following code in the text box that appears:
// Purge all WPO cache through Cron by Speedplus.com.ua WP_Optimize_Minify_Cache_Functions::purge(); WP_Optimize_Minify_Cache_Functions::purge_temp_files(); WP_Optimize_Minify_Cache_Functions::purge_old(); WP_Optimize_Minify_Cache_Functions::purge_others(); WP_Optimize_Minify_Cache_Functions::purge_temp_files(); WP_Optimize_Minify_Cache_Functions::cache_increment(); WP_Optimize()->get_page_cache()->purge();
Set Next Run to Now.
Select the Recurrence of the Cron event, for example, 12 hours.
Everything is ready, click the Add Event button, then check the cache size after a few minutes. If everything is done correctly, then the size of the cache folder will be reset and this problem will not bother you anymore.
If you were unable to configure automatic cache clearing on your site, you can contact us for help by creating a personal project using the link.