Support » Plugin: W3 Total Cache » How to change minified css file name?

  • Does anybody know how to generate a new file name for the combined css files?
    My problem is that users which doesnt clear their browser cache will see the old css
    styled page.

    Also after purging all caches the file name is still the same.

    Thanks for your help…

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Contributor gidomanders


    On clicking Purge All Caches, Minify should automatically regenerate and change filenames for CSS. You might want to change the Cache Control Policy for HTML & XML in Browser Cache to something like Cache with max-age and validation, because the pages could be in browser cache and you cannot remotely purge that.

    I have the same problem.
    The content of minified files is updated, but the address always remains the same

    Tried to change Cache Control Policy… with no luck =(

    It happens for me as well, the filename doesn’t changed when I purge all cache. I ended up add a prefix to the cache filename based on theme version.

      * Define Our Themes Version
      * this good if we update something and prevent old user browser cache
    global $themes_version;
    $themes_version = '2.1.2'; // Change this version everytime you change your css/js assets 
    add_filter('w3tc_minify_urls_for_minification_to_minify_filename', 'w3tc_filename_filter', 20, 3);
    function w3tc_filename_filter($minify_filename, $files, $type ){
        global $themes_version;
        $ver = sanitize_title( str_replace('.','', $themes_version) );
        $minify_filename = $ver.$minify_filename;
        return $minify_filename;

    Hope it helps someone

    Thanks for the fix hunio! This seems like something that should be handled better within W3TC but your fix works beautifully.


    I’m having the same issue.

    Unfortunately, Cache with max-age and validation does not work if the user has already cached the file.

    I’m using hunio’s approach, but I’m going to generate an md5 footprint of $files.

    I’m asking to plugin developers if it is possible to add an md5 footprint of the minified file to the filename, that will save a lot of headaches.

    Minified css file:

    Filename: c6e4b.81c7deb790e3bd97c67eb2a3a77c5b69.css

    Minified css file:

    Filename: c6e4b.6700e3e577966de91432a219303a54ce.css

    • This reply was modified 5 months, 2 weeks ago by giti.
    • This reply was modified 5 months, 2 weeks ago by giti.
    Plugin Contributor gidomanders


    @giti Indeed if the user has already cached a file with the wrong browser cache headers, then it doesn’t work, but nothing else will either. The user can clear the browser cache or the cache will expire after a while, only then the new headers will work for those users. For new users though, changing the setting will cause their browsers to display an always up-to-date website.



    this is really annoying issue, every time I clear the cache, the same css and js files are being referenced in the head and file names are not being changed.

    Thanks @hunio! your solution worked fine!



    @gidomanders The problem is, that you are not generating new names for minified files. If you would rename them, the user would be forced to download them again (even if the old one is cached in his browser). This is called cache busting and would be a nice feature for W3TC. That’s what the solution fro @hunio does, thx for that.

    Very good summary @tiiunder ! Definitly a feature request! Our customers always have outdated css files after quick changes.

    Hi. we got the same problem. Here is how we solved the unremoved cache problem. On the W3TC admin setting, pls go to ‘Browser cache’ setting then Check/Enable the option ‘Prevent caching of objects after settings change’. It’d add a suffix on the minified file.

    Thx @advcha,
    this does the trick without altering the functions.php.

Viewing 11 replies - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.