Cache folder getting big over time
-
hi Frank,
is it normal that the cache folder of cache/autoptimize/js gets incrementally bigger over time?
I can see new .js files written there and it seems is not getting purged, is that normal?
thanks,
Gabrio
-
Having the same issue with
phpandphp.nonefiles in thecache/autoptimizefolder.i do not have those files in cache/autoptimize
On holiday now, but have a look at the FAQ, it has some great info on this topic.
Btw Frank when you r back from holidays if you can share the 410 process for https://ww.wp.xz.cn/support/topic/some-404s that willbe great đ
Some feedback:
1. huge cache size typically is due to page- or request-specific JS (or CSS) which you should either exclude (see FAQ), or you could tell AO not to aggregate internal JS (or CSS) (see autoptimize_helper.php_example)
2. the .php-files (instead of .css/.js) is because you configured AO to deliver the CSS/JS dynamically, but the same principle from (1) applies.
3. 410: check đfrank
btw in the .htaccess I noticed that we have
Header set Cache-Control "max-age=10672000, must-revalidate"if that means a AO creates a new file every 3 hours (if that’s milliseconds), if I increase the size of that file, wouldn’t create less often new cached files?
I noticed my cached files in the cache/autoptimize/js seem to be created at more or less 3 hours intervals….
thanks
Gabnah, those are seconds and this is used by browsers (or proxies) to determine how long they can cache the autoptimized CSS/ JS.
frank
thanks Frank – I am still thinking what’s best solution for the growing js files in that folder. seems I get around 6mb in new .js every day or so.
I did take 2 blog posts and compared their js files as you suggest at http://blog.futtta.be/2014/03/19/how-to-keep-autoptimizes-cache-size-under-control-and-improve-visitor-experience/ but could not find any difference, they were exactly the same.
I am thinking that one of the plugins might change “something” so that a new .js file needs to be written. since I didn’t add any posts in a specific time period, it’s a bit odd. perhaps something in my theme though. as I was saying I get a new .js every 3 hours approx.
Gab
the name of the file is autoptimize_<md5($content)>.js (or .css). this implies that if the content is identical (to the comma), the name is the same and the cached file can be used. a file with a different name has a different hash meaning it must have something (a space, a comma, a digit, a newline, …) different in there.
don’t know if you did already, but if not you could force AO not to aggregate any inline CSS or JS (which in 99.9% of the use cases are the reason for cache-misses and hence cache size increases) by using the API;
add_filter('autoptimize_js_include_inline','gad81_ao_include_inline',10,1); add_filter('autoptimize_css_include_inline','gad81_ao_include_inline',10,1); function gad81_ao_include_inline() { return false; }For AO 2.0 enabling/ disabling inline aggregation will become an option in the settings-screen (replacing the “look only in head”-options).
frank
hey Frank, let’s give it a go…
sorry for the noob question here, how do I “use” the API? do I need to add those lines to autoptimize.php ?
tnx
Gabhow do I “use” the API? do I need to add those lines to autoptimize.php ?
No, add that code to your (child) theme’s functions.php (do take into account that theme updates would remove the code) or into a seperate mini-plugin.
frank
seems something’s wrong… I added it and I get
add_filter(‘autoptimize_js_include_inline’,’gad81_ao_include_inline’,10,1); add_filter(‘autoptimize_css_include_inline’,’gad81_ao_include_inline’,10,1); function gad81_ao_include_inline() { return false; }
displayed at the top of the page…
well, where did you add it? is it in between php-tags to ensure it gets executed?
got it đ seems to work now, I can see javascript now that is “expanded” in the code.
let’s see what happens, I will leave it for a few days.
thanks again Frank!
The topic ‘Cache folder getting big over time’ is closed to new replies.