How to fix Autoptimize cache size warning

Autoptimize

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 the 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 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.

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

Autoptimize cache size warning

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, clicl on 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 max cache size in Autoptimize if your server has enough free storage. Add the following code in 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 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.

Autoptimize cache size warning

That’s it.

Now you know how to clear Autoptimize cache or keep Autoptimize cache under control.

Advertisement

Tags: |

Deepanker Verma is the founder of Techlomedia. He is a tech blogger, developer and gadget freak.


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.

2020 UseThisTip | Part of Techlomedia Internet Pvt Ltd Developed By Deepanker