The purpose of the CSS/JS caching directory which by default is /wp-content/cache/asset-cleanup/ (it can be changed to a custom location) is allowing faster access to optimized files (e.g. minified/combined or altered in any way) and save resources by avoiding the optimization to be performed on each page request.

For example, you might have 20 stylesheet files that are non-minified and you enable “CSS Files Minification”. The minification for each of the files takes time and if some files are really large it can add up to the total time the files are generated, not only using more server resources (e.g. CPU/memory) but also taking time until the page is loaded, increasing the TTFB (time to the first byte) which is not good for the user experience and ranking in search engines such as Google. Thus, the minified versions of the original CSS files are created in the caching directory and when those files are loaded again, the minification will be skipped and their already minified versions will be loaded from the cache. This would speed up the loading time considerably.

What if the original source file located within a plugin/theme is already optimized?

In the example that was just mentioned, if the CSS file is already minified to the point there are no changes to be done, then there’s no point in creating a cached version, and to save disk space, Asset CleanUp will let the original file to load instead. That’s why you could notice that some files are left intact with no reference to /wp-content/cache-asset-cleanup/ at all.

In which circumstances a file gets altered and has its new version loaded from the caching directory?

First, note that any original files from any plugin or theme are always left intact and Asset CleanUp will never change them in any way. If the file is originating from a plugin or your theme, then it will always be stored there and never altered, renamed or deleted. Asset CleanUp only creates alternative & optimized versions of those files and loads them from its caching directory. If you deactivate the plugin, it will be like it wasn’t activated in the first place. All the files from your website will keep their integrity. It’s a bad practice to directly alter the files from an existing plugin and it should be avoided as much as possible unless you’re a developer and you truly know what you’re doing. If that particular plugin or theme gets a new update, you guessed it, that update will overwrite any custom changes that were done to that plugin. That’s why WordPress actions & filters as well as other functions are coming into place.

Chances are you will have optimized files loaded from the caching directory if any of the following features are enabled in Asset CleanUp that require a change of the CSS content in any way:
For CSS Files:
  • Optimize CSS
    • CSS Files Minification
    • Combine loaded CSS (Stylesheets) into fewer files
    • Inline CSS Files * if the targeted file is bigger than 40KB, but smaller than 500 KB to avoid using too many resources
    • Cache Dynamic Loaded CSS
  • Local Fonts Optimization
    • Apply font-display: CSS property value * only relevant in the Pro version
  • Google Fonts: Load Optimizer
    • Apply font-display: CSS property value
    • Remove Google Fonts
For JavaScript Files:
  • Optimize JavaScript
    • JavaScript Files Minification
    • Combine loaded JS (JavaScript) into fewer files
    • Inline JS Files * if the targeted file is bigger than 40KB, but smaller than 500 KB to avoid using too many resources * only relevant in the Pro version
    • Cache Dynamic Loaded JavaScript
  • Google Fonts: Load Optimizer
    • Apply font-display: CSS property value
    • Remove Google Fonts

When is the cache re-built and the optimized cached files updated?

The caching expires in 24 hours and the optimized file is re-built after this time passes OR whenever the contents of that file is updated, whichever happens first. If the original source file is no longer loaded (e.g. you decided to unload it or you just no longer use the plugin that loaded it in the first place), then whenever the caching is clearing, it will get deleted sooner or later based on the setting from “Settings” – “Plugin usage preferences” – “Clear previously cached CSS/JS files older than (x) days” – You might have cached pages (e.g. either via a plugin such as WP Rocket or through your hosting own caching system) that are still referring to the old file, including the pages indexed by Google that can be previewed by your visitors. You don’t want to have those cached files deleted immediately in case they are still loaded. That’s why a period of 7 days is the standard one (more than enough in most cases) to leave those files in place and not having them deleted. If you set the value of “Clear previously cached CSS/JS files older than (x) days” to 0 (it’s up to you, depending on the server-side caching system you might be using), then all the non-active CSS/JS files will be deleted, leaving the most recently created ones that are still needed (e.g. you changed the “ver” of a CSS file from ‘3’ to ‘4’; The optimized CSS file that had the versioning set to 3 will be deleted, leaving the ‘4’ in place).

What if I stop using any of the features that are creating these optimized files?

In this case, the caching directory will gradually get clearer and the CSS/JS files will be deleted. You can avoid using any of the features from “Settings” that were just mentioned and would cause the creation of the optimized files. Some users, before installing Asset CleanUp were using other performance plugins to optimize the files and decided to install Asset CleanUp on top of that to unload CSS/JS files (which do not require any caching at all), thus improving the performance even more.

My caching directory has lots of files and it’s taking plenty of space on the disk. How can I reduce its size?

If the total size of the /wp-content/cache/asset-cleanup/ directory is still big even after you cleared the cache, then you can try some of the following to reduce its size after the next cache clearing:

  • Unload more CSS & JavaScript files (be careful with that and make sure you unload only what’s not needed), this way, there will be less remaining loaded CSS/JS files and as a result less optimized files in the caching directory. This is also valid if you’re using Asset CleanUp with any other plugins that are using their own caching directory such as WP Rocket, Autoptimize, etc.
  • Exclude already minified CSS/JS files from being re-minified by Asset CleanUp; the plugin already does that and no minify process is triggered if a file is already optimized. However, there are situations when you have files that are very well optimized and it’s not worth squeezing it for the sake of saving 3% of its total size, especially for large files that have hundreds of KB in size. For example, you could have a file that has a size of 300 KB. It has some comments in it and a bit of code that is left not minified (e.g. ~10 KB of extra comments). Going through the file and minifying it could take up resources, especially if you have a few of these kinds of files. Moreover, if you enable combine CSS/JS, it will also be added to the combined optimized files, thus, not worth in using all these resources, especially if the file is not render-blocking.
  • If you have enabled combine CSS/JS, consider deactivating the option (via “Asset CleanUp Pro: Options” meta box when you edit the page) on pages that are not meant to be cached such as Checkout, Cart, My Account, Customer Dashboard, etc. This feature is supposed to provide faster loading for websites that are on the HTTP/1 protocol (many servers support HTTP/2 now: and works best if the page is visited by guests.

Was this post helpful?