• Resolved danescobar

    (@danescobar)


    Hello @optimizingmatters

    I’m trying to write a snippet so I can autoclean AO’s cache if it gets over 100Mb but it doesn’t work getting easily over 300Mb because I chose to activate “aggregate inline JS” given the performance increase it has on my website.

    • Could you help me improve the code below to make it work?
    • Also I noticed when cache is below 100Mb server’s “Physical Memory Usage” is around 30% (300Mb/1Gb) and when the cache is 300Mb usage is 70% (700Mb/1Gb) what would be the ideal limit size of AO’s cache for an optimal Physical Memory Usage?
    if (class_exists('autoptimizeCache')) {
        $myMaxSize = 1024000; # What value would be ideal for 1Gb physical mem?
        $statArr=autoptimizeCache::stats(); 
        $cacheSize=round($statArr[1]/1024);
        
        if ($cacheSize>$myMaxSize){
           autoptimizeCache::clearall();
           header("Refresh:0"); # Refreshes page so AO can create new files.
        }
    }

    Thanks for your attention.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Optimizing Matters

    (@optimizingmatters)

    I don’t believe in auto-cache clearing for many sound technical reasons explained in the AO FAQ, but that same FAQ has links to 3rd party solution that do exactly what you want to do, so maybe have a look there @danescobar ? 🙂

    Thread Starter danescobar

    (@danescobar)

    Oops thanks for the heads up, I should have read that section before asking.

    I’ll definitively try the method of comparing similar posts to locate similar lines and add JS and CSS exclusions. Thanks for that blog entry.

    One thing I noticed is that, around 300Mb, the cache stabilizes and doesn’t grow more, the server keeps the physical memory usage at 70% and in the yellow. How could I measure if, at that level of memory usage, visitors to my site might be experiencing performance issues? A speed test in GTMetrix or Webpagetest could give me information about my webpage navigation or performance slowing down?

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    I see no logical link between AO cache size and physical memory usage to be honest.

    if your cache size stabilizes, then from AO’s point of view there is no fundamental problem really. it’s only if your cache size continues to grow that you should worry about visitors having to wait for CSS/ JS to be minified (as not in cache). 300mb is late to reach that stabilization point, could indicate that each page has different autoptimized CSS and/ or JS?

    Thread Starter danescobar

    (@danescobar)

    I see no logical link between AO cache size and physical memory usage to be honest.

    Yeah I first thought the same but as soon as I cleaned the cache the physical memory usage of the server went from 70% to 30%.

    300mb is late to reach that stabilization point, could indicate that each page has different autoptimized CSS and/ or JS?

    Most probably because I use Elementor (plus addons widgets) in my shop section and the Gutenberg editor for the blog posts. I’m guessing these Elementor widgets could be the culprit adding additional JS and CSS to the webpage.

    Since it will take quite a bit of work I will do the compare method you described in your blog eventually in the future. For now I deactivated “Aggregate inline JS”.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Scripting to Autoclean AO’s cache’ is closed to new replies.