WordPress.org

Ready to get started?Download WordPress

Forums

W3 Total Cache
Refresh query string for assets (4 posts)

  1. Jesse Gardner
    Member
    Posted 1 year ago #

    There's an option in the settings: "Prevent caching of objects after settings change"

    I have this checked because I want the query string appended to my assets. However, I'm not sure what "settings changes" causes the query strings to change. I'd like to be able to force those query strings to update without clearing the entire page cache.

    Specifically, I'd like to be able to make a change to the stylesheet and have the query string read styles.css?newfoo123 — and I'm ok waiting for natural page expiration (15 min) since a full page cache purge is resource heavy. But my stylesheet expiration is set to a week and I don't want to wait the week for users to download the updated stylesheet.

    Is there any way to force W3TC to update the query strings appended to assets?

    http://wordpress.org/extend/plugins/w3-total-cache/

  2. Manuel Razzari
    Member
    Posted 1 year ago #

    I'm interested in this as well. Seems like it would be a pretty useful feature. (Ideally, also offering style.a2b3c4.css URLs)

    Otherwise, the only way to get this feature from the plugin seems to be by minifying assets.

  3. stinoga
    Member
    Posted 1 year ago #

    You guys find an answer to this? I'm also interested...

  4. stinoga
    Member
    Posted 1 year ago #

    Ok, I've got a pretty decent solution for this. I've appended a version number to my CSS and JS based on the file modified times. This busts the cache after I deploy any changes to these files. I minify all my css and js into one file each, so I need one variable for each file, for example:

    $cacheBusterCSS = filemtime( get_stylesheet_directory() . '/library/css/style.css');
    $cacheBusterJS = filemtime( get_stylesheet_directory() . '/library/js/scripts-ck.js');

    wp_register_style( 'bones-stylesheet', get_stylesheet_directory_uri() . '/library/css/style.css', array(), $cacheBusterCSS, 'all' );
    wp_register_script( 'bones-js', get_stylesheet_directory_uri() . '/library/js/scripts-ck.js', array( 'jquery' ), $cacheBusterJS, true );

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic