Browser caching meaning old CSS is loaded
-
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.1This 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]
- The topic ‘Browser caching meaning old CSS is loaded’ is closed to new replies.