• Resolved webaware

    (@webaware)


    With the new method of not reminifying already minified CSS (yay!), there’s a slight glitch: changes in those CSS files don’t change the hash any more, so the filename stays the same. This means that a plugin or theme update can’t bust caches (e.g. browser cache, CloudFlare cache).

    The hash needs to take into consideration the script / stylesheet version, so that it changes when they do.

    cheers,
    Ross

    https://www.ads-software.com/plugins/autoptimize/

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

    (@futtta)

    darn, that indeed is a regression we did not consider.

    problem is a version isn’t readily available; the ?ver=x.x parameter is not related to the version of the file as such, but is -if I’m not mistaking- added by wordpress as a generic version-string which changes with the wordpress-version.

    anyway, I’ll give this a good think … in the mean time you could disable the new method (cfr. FAQ)?

    frank

    Thread Starter webaware

    (@webaware)

    Yeah, I looked at the code and it’s currently throwing away any query parameters. I reckon you could store them as another member of the $css array, and recombine when building the %%INJECTLATER%% path to get a unique hash. And you’d probably need to grab the whole query string because some scripts / stylesheets could be directly injected with who-knows-what parameters (ver=x.x, v=abc, nocache=yyyy-mm-dd, etc)

    I’m OK for now (cleared CloudFlare cache of the .css files), and if I have to (e.g. a WooCommerce upgrade) I can fudge it with some null inline CSS ??

    cheers,
    Ross

    Plugin Author Frank Goossens

    (@futtta)

    Hiya Ross;
    I ended up with another solution, cfr. https://github.com/futtta/autoptimize/commit/afb2948d21b471be7aeb398e871819d405e18631

    -> before minification not only the path to min.css (or min.js) but also a hash of the content of that file is added to the aggregated file
    -> if the contents of a minified file changes, the hash of that file obviously changes as well, which in turn results in the hash of the aggregated file (which is the ‘random’ part of the autoptimized filename) changing as well
    -> after minification the path&hash of the already minified files is replaced by the content of those same files

    Would be great if you could test this change either by updating the code manually (only 4 changed lines) or by downloading the zip straight from GitHub.

    frank

    Thread Starter webaware

    (@webaware)

    Yup, that did it. It’s even better because it detects actual changes, so:

    * it won’t bust the cache when the version is bumped but nothing changed
    * it will bust the cache when dodgy plugins/themes lie about versions

    ??

    cheers,
    Ross

    Plugin Author Frank Goossens

    (@futtta)

    great, thanks for the bug-report and the feedback Ross!

    have a ball,
    frank

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Changes to minified CSS no longer change compressed file name’ is closed to new replies.