Support » Plugin: Autoptimize » Up to 30gb of optimized files ?

  • Resolved Raz

    (@razique)


    Hi,
    I’m currently using the latest version of the plugin.
    I just found out yesterday that the plugin created up to 30 GB of optimized files. And I’ve looked in the settings, there is not any cache timeout of Garbage Collector.

    I was thinking about creating a cron that would deleted files that are 2 days older or something, or did I missed something?

    thanks a lot!

    https://wordpress.org/plugins/autoptimize/

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author Frank Goossens

    (@futtta)

    Well … having a cache pruning mechanism is on my wish-list, but the fact that it’s not there yet is because it isn’t necessarily easy if you use page caching component (most of the times a plugin such as wp super cache or alternatively a caching reverse proxy such as varnish) to accompany Autoptimize, which I consider the default setup. In that case the aggregated CSS/JS should remain available for at least the time the pages are in the page cache (because otherwise requests for Autoptimized CSS/JS results in 404 errors).

    The reason for a cache size that grows to big in general is the fact that your pages have code (in general JS) that varies with every page (e.g. a unique ID per page used by an affiliate marketing plugin, see this thread for an example). Excluding that JS from being aggregated will drastically limit your cache size, to the extend that cache pruning becomes a nice to have instead of a hard requirement.

    Hope this helps,
    frank

    Thread Starter Raz

    (@razique)

    Thank you Frank, I have thousands of files created everytime, so I will try to see if excluding the JS is worth it.
    As for the cache managed by other services, I don’t understand, how they are suppose to delete the created files by themselves?
    I’m using W3 Total Cache next to it, but currently considering WP Super Cache instead. How do I “connect” them to have the files created by Autoptimize (stored in wp-content/cache/autoptimize) managed by my caching plugin?

    thanks
    Razique

    Plugin Author Frank Goossens

    (@futtta)

    excluding ever-changing JS will most certainly be worth it, as you will have significantly less files in the autoptimize-cache-folder and it will re-use of aggregated JS/CSS in the browser cache.

    regarding wp super cache or W3TC; no off the shelve solution, just pointing out that automaticallyremoving autoptimized files that are 2 days old might not be the best solution. it is something I plan to work on, but no idea how, yet.

    Thread Starter Raz

    (@razique)

    Thanks it’s the plugin “commentLuv” that generates a “referrer” string I think.
    But I cannot exclude the scripts.
    What is the exact string this field expects?

    The file only, such as: “commentluv.js”
    the path, or the URI?
    thank you! 🙂

    Plugin Author Frank Goossens

    (@futtta)

    I think in this case you don’t have to exclude a javascript-file, but rather an inline blog of javascript. So I had a very quick look at commentluv source, I think excluding “cl_settings” might be enough. If this doesn’t work let me know and when I some have time I’ll install myself on a testblog and play around with it.

    frank

    Thread Starter Raz

    (@razique)

    Ok will try
    How did you figured this one out?
    I have another that needs to have the JS loaded in the header as well,
    but I still don’t get it where the string to exclude comes from.
    is it a variable name? An handler? a js file without .js?

    It’s too bad to have the Js compression disabled and the “look for scripts in head” only because I’m still unable not to figure the thing to, it’s something I’d like to do for other websites as well 🙂

    best
    Raz

    Plugin Author Frank Goossens

    (@futtta)

    well, random (unique) vars in javascript have to be set by php, so the javascript to exclude should either be in the php-code of the plugin or in a JS-file which is generated on the fly by php. I then scanned the PHP-code for commentluv for “javascript” and found this:

    $data = "var cl_settings = {";
                $arr = array();
                $vars = $this->localize;
                if(is_array($vars)){
                    foreach ($vars as $key => $value) {
                        $arr[count($arr)] = $key . " : '" . esc_js($value) . "'";
                    }
                    $data .= implode(",",$arr); $data .= "};";
                    echo "<script type='text/javascript'>\n";
                    echo "/* <![CDATA[ */\n";
                    echo $data;
                    echo "\n/* ]]> */\n";
                    echo "</script>\n";
                }

    This block of php-code seems to write out vars from a PHP-array into a javascript-block. The javascript-block starts with “var cl_settings”, meaning we should be able to exclude it from aggregation by adding “cl_settings” as exclusion-string.

    Hope this makes sense & helps you out!

    kind regards,
    frank

    Thread Starter Raz

    (@razique)

    Ok thank you
    So it’s not really a “script” as stated – I’m battling for hours about finding the script name everytime.
    Maybe two options would be better?
    something like
    “path to the script to exclude – for example my-plugin/inc/test.js”

    and the “javascript vars”
    does that make sense?

    Thread Starter Raz

    (@razique)

    It worked,
    thank a lot futta

    Plugin Author Frank Goossens

    (@futtta)

    you’re welcome 🙂

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Up to 30gb of optimized files ?’ is closed to new replies.