• Resolved linzD

    (@linzd)


    I have a WordPress install where our CSS is compiled into a .js file as part of our buildstep.

    Obviously we deploy new CSS code from time to time, and when we do we want any return visitors of our website to have the latest code.

    How we achieve this

    When enqueuing this main-bundle.js file, using wp_enqueue_script() we provide a version number, which is (normally) appended onto the end of the file name e.g. main.bundle.js?ver=24.04.1

    This means when we update our CSS, we update our version number. Browsers treat this as a new file and load the new code.

    The issue

    However, when using Speed Optimiser the contents of this file are loaded by other means (presumably lazy loading).

    Accordingly, when we change our CSS code, the old code remains in browser cache.

    How can we stop this happening?

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Preslav Kenanov

    (@preslavkenanov)

    Hello @linzd,

    Please check if the Remove Query Strings from Static Resources is enabled. If that is the case, it is expected to not purge the cache, since there are no modifications to the html markup. If the cache is purged as expected then you can exclude static resources from the removal of their query strings using the custom filter we’ve designed for that purpose which is:

    add_filter( 'sgo_rqs_exclude', 'sgo_rqs_exclude_scripts' ); function sgo_rqs_exclude_scripts( $exclude_list ) { $exclude_list[] = 'part-of-the-resource-path.js'; return $exclude_list; }

    If that doesn’t help, it would be best if you submit a ticket via our Help Desk as this will allow us to review your case in detail and provide you with more accurate information specific to your case.

    Regards,
    Preslav

    Thread Starter linzD

    (@linzd)

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Browser caching meaning old CSS is loaded’ is closed to new replies.