How to fix Autoptimize cache size warning

Autoptimize cache size warning

I personally use Autoptimize to minify and aggregate JS and CSS files on my blogs. I also recommend this plugin to my clients. This plugin works really well but there’s one thing big websites could face. Recently, I started receiving emails with the title “Autoptimize cache size warning” on a regular basis for one of my sites. When I checked, I was surprised to see the Autoptimize cache size larger than 750 MB for my website. If you are using Autoptimize plugin, you may also face the same. So, I am here with a solution to fix this issue and stop receiving warning emails.

Autoptimize cache size warning

Autoptimize aggregates all JS and CSS files into one JS and CSS file. Every time a web page loads, it calculates the hash of the new aggregated JS and CSS file and compares it with the cached version of the files. If it finds a difference, it aggregates CSS/ JS in a new cache file. There are several plugins that put inline JS and CSS. So, not all pages will have the same JS and CSS code. This leads to Hash mismatch on different pages and it leads to a huge amount of cache files.

Best Managed WordPress Hosting

WPEngine is the best and most secure managed hosting provider

If you are also receiving the “Autoptimize cache size warning” for your website, you can solve this by following this step.

The first thing you need to do is to uncheck the “Also aggregate inline JS?” and “Also aggregate inline CSS?” option from the Autoptimize settings page and save. Unchecking this option will prevent the plugin from creating multiple caches for JS and CSS due to inline CSS and JSS. It will limit the cache size under control.

After unchecking these options, click on the button Save Changes and Empty Cache. It will remove the cache to start the cache process from the beginning.

The reason why cache size grows to be big is that the plugin doesn’t feature automatic cache pruning. This is to avoid the plugin from breaking your pages.

You can also increase the max cache size in Autoptimize if your server has enough free storage. Add the following code to the functions.php file of your theme.

add_filter('autoptimize_filter_cachecheck_maxsize','change_maxsize');
function change_maxsize() {
return 1010241024;
}

If you do not want to edit code and still want to manage the Autoptimize cache properly, use the Autoclear Autoptimize Cache plugin. This plugin helps you set the max cache size and also clear Autoptimize cache whenever you want. This plugin’s settings panel looks like the screenshot below.

fix Autoptimize cache size warning

That’s it.

Now you know how to clear the Autoptimize cache or keep the Autoptimize cache under control. I hope this article was useful. TheWPGuides has several WordPress articles that will surely help you understand WordPress in a better way.

Tags: | |

Deepanker Verma is an experienced WordPress developer who has been working on WordPress for more than 12 years. On TheWPGuides, he writes about WordPress, WordPress development, and WordPress plugins.


Similar Articles

0 Comments

Leave a comment

Comment policy: We love comments and appreciate the time that readers spend to share ideas and give feedback. However, all comments are manually moderated and those deemed to be spam or solely promotional will be deleted.

© 2022 The WP Guides Developed By Deepanker