Support » Plugin: Better WordPress Minify » wp-cli or flush cache from command line

  • I understand you don’t have a wp-cli integration yet – however this makes things a bit tough for automated deployments. When CSS/JS files change, we would have to go into each install and flush cache manually.

    Is there a way to trigger a flush cache from command line?

    Or could it be added to the plugin deactivate/activate functions to keep it simple?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Khang Minh



    When CSS/JS files changed you don’t actually need to flush the cache directory. Flushing the cache directory won’t help anyway for old users if user does not press F5 or Ctrl+F5. Once F5 or Ctrl+F5 is pressed cached files are checked against current files (now changed) and are updated automatically.

    You can, however, add a cache buster to the minify string by applying a filter to this hook: bwp_minify_get_src, something like:

    add_filter('bwp_minify_get_src', 'append_cache_buster');
    function append_cache_buster($minify_string)
        return $minify_string . '&ver=' . '1234567890';

    I don’t understand the cache buster part – e.g. that it’s not updated if the source files change – aren’t you creating md5 based on the source css/js files date timestamps or checksums?

    so if i have style.css and style1.css i have another checksum than when style1.css was being altered meanwhile? the ctrl+f5 idea is not a good solution

    ( i mean i understand it programmatically, but i thought bwp was taking care of file changes already )

    Hey Khang,

    Is it possible to adjust the filename of the generated css/js file based on the md5 checksum of the contents?

    That way could push the css files to CDN without fearing for cache issues, and could drop the ?ver= parameters which are bad for frontend caching and micro cache proxies like varnish.

    E.g. right now the .js result I get is this :


    Once I change one of the files, it currently just changes the last part of the url ( the ver= part )


    Any way to simply change the 684c1e3d23b06bc0b7d1a6d2ed4e90de checksum based on the file contents instead?

    Plugin Author Khang Minh


    Changing the hash sounds like a good idea, however not possible at the moment. You can modify the code to achieve that (file includes/class-bwp-minify-fetcher.php), for example:

    $group_hash       = md5($original_string . $detector_version . apply_filters('bwp_minify_build_number', ''));

    and then add a filter at a suitable place.

    Thanks Khang

    I’ll review and send you a PR to github, so your future updates won’t overwrite those changes šŸ™‚

    Plugin Author Khang Minh


    Have you ever got the chance to create a PR :)?

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘wp-cli or flush cache from command line’ is closed to new replies.