• Resolved Greg Marshall

    (@timeassistant)


    Hey there,

    First things first. I love your plugin, I had to start using it after w3tc was becoming overly problematic in terms of handling the CSS & JS. Unfortunately our site seems to need a reoptimsation every couple of months as it can go from an A rating on pagespeed to an E… But that’s not the reason I am here…

    Anyway, under the plugin settings there is the following info line:

    Cached styles and scripts xxx files, totalling xxxx Kbytes (calculated at 17:15 UTC) MY current time is 1800 UTC at the time of writing.

    My problem here is that 45 minutes (or more) is a long, long time to wait if I would like quick easy info from the plugin about its current cache size etc.

    Especially just now as I am trying to aggregate and inline and as expected it is rattling the you know what out of my disk space :D… Is there a way to either force a manual cache info update, or in general just make it update more often? Even if it is as some kind of debug option or something to define in functions or wp-config?

    I am aware frequent indexing of the cache files can ultimately slow things down, but in the case of testing its a necessary evil for me

    anyway I look forward to a response, please also keep up your good work here !! your plugin is definitely one of a kind right now

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

    (@optimizingmatters)

    good question Greg 🙂

    the stats are stored in a wordpress transients for 1h, cfr. wp-content/classes/autoptimizeCache.php;

    set_transient("autoptimize_stats",$AOstats,HOUR_IN_SECONDS);

    So you could:
    * use “transient manager” plugin to clear the autoptimize_stats transient
    * use the same plugin to could temporarily disable all transients.
    * change the code, replacing HOUR_IN_SECONDS by MINUTE_IN_SECONDS

    hope this helps,
    frank

    Thread Starter Greg Marshall

    (@timeassistant)

    Thanks for the quick reply !

    The transient manager is probably the simplest solution.

    However I would quite like to change the code but, I don’t want to edit the plugin directly I’d obviously lose the changes between updates. A quick google search led me to this post https://iandunn.name/2014/01/10/the-right-way-to-customize-a-wordpress-plugin/

    Would any of this work with AO?

    Thanks again

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    OK, I just added a filter in the dev-version (on GitHub) that should allow you to override the expiration by hooking into it and changing the value to your own liking. You can download the zip-file (which has a lot of other goodies in it) from https://github.com/futtta/autoptimize/archive/master.zip

    Thread Starter Greg Marshall

    (@timeassistant)

    wow that’s amazing thanks

    I am trying to create a plugin with a settings page that would manipulate this without having to edit code every time. (Using the wp boilerpate from https://wppb.me/)

    This is my first plugin attempt so I am actually stuck!!! Will have to research tomorrow and try get going again…

    Nonetheless thank you very much for adding the filters, hopefully I’ll be able to learn what I need and finish this off

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    the easier approach might be to start off with the code snippets plugin and get the basic code hooking into the filter working (I could tell you, but maybe you prefer learning by yourself) in a simple code snippet. once that works you can integrate it into a separate plugin, with, to put the cherry on the cake, with a settings page? 🙂

    Thread Starter Greg Marshall

    (@timeassistant)

    Yes I think I jumped in at the deep end there !

    I actually created a settings page with the input field. It was the rest of it that got me stuck 🙂

    I am attempting to hook into the filter just now using a snippet, I do like to try and teach myself however I would happily accept some starting off pointers. Unfortunately the available docs on WP are generally for creating your own plugins and code or manipulating default WP core stuff – not manipulating someone else’s plugin 😉

    Thanks

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    well, haven’t tested this specific filter, but something like this should work;

    add_filter('autoptimize_filter_cache_statsexpiry', MINUTE_IN_SECONDS);

    might just work 🙂

    Thread Starter Greg Marshall

    (@timeassistant)

    Ah cool thanks,

    I was trying to do something like this:

    function ao_custom_refresh( $duration ) {
        $duration=120; 
    
    	    
            return $duration;
        }
    
     add_filter( 'autoptimize_filter_cache_statsexpiry', 'ao_custom_refresh' );

    but it seemed to be refreshing every 60s anyway so I will swap it out for your code.

    In terms of that do you think

    add_filter('autoptimize_filter_cache_statsexpiry', 120);

    would work? or would it be

    add_filter('autoptimize_filter_cache_statsexpiry', 2 * MINUTE_IN_SECONDS);

    Thanks again !

    • This reply was modified 8 years, 3 months ago by Greg Marshall.
    Plugin Author Optimizing Matters

    (@optimizingmatters)

    no, i’m totally wrong actually, you indeed need something like;

    function ao_custom_refresh() {
            return 120;
    }
    add_filter( 'autoptimize_filter_cache_statsexpiry', 'ao_custom_refresh' );

    sorry for the confusion
    frank

    Thread Starter Greg Marshall

    (@timeassistant)

    Hey Frank,

    No problems at all ! I’m just thankful for your excellent support 😀

    I’m glad I was close with my example, good to know I was on the right track at least – the self teaching is still proving to be mostly useful….

    Anyway I have altered the code again and it seems to be working great. Its updating every 120 secs which I will probably increase to a longer duration now that its working and I am about to finish for the holidays.

    Which leads me back to the plugin – probably won’t be til after new year now but I am definitely going to try and convert this into a plugin as mentioned before with a settings page to change the refresh rate on the fly and to “pay it forward” I think I will probably upload it to the WP repo aswell for others who may want it – assuming you have no objections as its an addon to your plugin (also assuming I get it working !!!!)

    Anyway you’re an absolute legend Frank ! By way of thanks please do let me know if I can be of any assistance with AO moving forward, (as I have your dev version on our live site I plan on playing with the extra features when I get some time and I’ll give any feedback as/when it comes up)

    Hoe you have yourself a great Christmas (if you celebrate it!) and New year.

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    assuming you have no objections

    none what-so-ever @timeassistant

    playing with the extra features when I get some time and I’ll give any feedback as/when it comes up

    that would most certainly be helpful 🙂

    have yourself a great Christmas (if you celebrate it!) and New year.

    and you!

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

The topic ‘Reduce time between “Cache Info” updates’ is closed to new replies.