How to control the Autoptimize cache • WordPress Help

In case you do not know, Autoptimize is a fantastic WordPress plugin with which to minimize your code so serve your pages faster .

But in certain conditions and configurations can generate a very large cache that would take up a lot of space and you'll have to be manually emptying it every so often, which is a pain in the ass .

Why does the Autoptimize cache grow so much?

The size of your site cache goes in direct proportion to the amount of code on your website to all files and HTML codes , CSS and JS to keep minimized for to serve these files from the Autoptimize cache instead of rendering them complete and unimproved at each visit .

And the thing becomes immense, besides , if you activate the settings include the embedded JS and CSS ( inline ).

 JS inline in Autoptimize

 CSS inline in Autoptimize ]

So one way to keep the Autoptimize cache under control is to not activate those two boxes, but only if your cache goes up to a level where the indicator turns red and you get the warning from the cache.

Why does not Autoptimize empty the cache alone?

Good question. The answer is that a very large minimized file cache is a warning that something is not fine as you may be generating too many minimized files, and what you should do is keep them at bay.

it is especially important in very large sites with a lot of content, where there is a lot of HTML, CSS and JS code to be minimized.

The problem of the self-cleaning of the cache would be that many operations to clean the cache and this could slow down your website which is just what we do not want.

On the other hand, if you do not control the size of the cache it will consume a lot of disk space on your server.

So what do I do?

My recommendation is that, in principle, do not do anything . You minimize everything, even the embedded JS and CSS, and if Autoptimize does not warn you, leave it so it is the most optimal configuration to improve loading times for your website .

Also, Autoptimize warns you based on good . You will see the Autoptimize indicator in red, it will show you a notice on the desktop and even send you an email, so for lack of information it will not be.

If it is not very serious, if it does not happen very often , that you go through your WordPress and erase the cache is enough . Simply put the cursor over the icon (green or red according to the size of the cache) of Autoptimize, and clear the cache.

Let's say that the only problem is that you do not you have no space on your server.

Now, if you receive notices of very large cache sizes, say more than 1Gb then it is still better to disable the embedded JS and CSS as we have seen before

But what if you want to have all the minimized settings active but with the cache under control?

If you want to minimize your content while keeping the Autoptimize cache you can force the automatic emptying of your cache, for which you have 2 methods.

Empty the Autoptimize cache with a code

Just add this code to the file functions.php of the topic active or your utility plugin, changing the value maximum of the cache to your liking:

In this example you will see that I have set the automatic deletion when it reaches 1Gb, but adapt it according to the space you have on your server by changing the value after $ myMaxSize .

Empty the Autoptimize cache with a plugin

If you prefer, you can do the same with the BI Clean Cache plugin with which you can set a CRON for that flushes the Autoptimize cache when you decide.

Loading …

That may also help you: