style.css?ver=6.4) are how WordPress busts browser and CDN caches when a theme or plugin updates a file — but some caching/CDN layers and page-speed testing tools flag them as a performance issue, since certain proxies won’t cache a URL that includes a query string.
Option 1 — A Caching Plugin Setting
If you’re already running a caching plugin (LiteSpeed Cache, WP Rocket, and others), check its optimization settings first — most include a one-click “Remove query strings from static resources” toggle that handles this without touching any code.Option 2 — A Small Code Snippet
If you’d rather not rely on a plugin setting, this snippet in your child theme’sfunctions.php strips the ver parameter from enqueued styles and scripts:
function tgh_remove_query_strings($src) {
if (strpos($src, 'ver=')) {
$src = remove_query_arg('ver', $src);
}
return $src;
}
add_filter('style_loader_src', 'tgh_remove_query_strings', 10, 1);
add_filter('script_loader_src', 'tgh_remove_query_strings', 10, 1);
Note that removing the version query string also removes its cache-busting function — if you (or a plugin) update a CSS/JS file, visitors’ browsers may keep serving a stale cached copy until their local cache naturally expires, so weigh the modest speed-test score improvement against that trade-off.
Is This Still Worth Doing? (Updated for 2026)
Worth flagging up front: this is now a deprecated recommendation. GTmetrix’s own guidance page for it is titled outright “Remove query strings from static resources (deprecated)” — the original rationale (older proxies like Squid 3.0 refusing to cache a URL containing a?) stopped applying once modern CDNs and browsers began caching based on Cache-Control response headers rather than URL syntax. Current Google Lighthouse/PageSpeed Insights audits don’t check for query strings at all — the nearest modern equivalent is “Serve static assets with an efficient cache policy,” which has nothing to do with a ?ver= string. WP Rocket removed its own version of this toggle back in version 3.6, with the development team stating outright that GTmetrix no longer factors query strings into its performance grades. If you’re setting up caching on a current build, skip this one and look at filename-based cache busting instead — baking a content hash into the filename itself (e.g. style.a1b2c3.css) paired with a long, immutable Cache-Control header gets you both aggressive caching and reliable invalidation, without the URL-syntax workaround this post describes.
Resources
- previous post
- Kinsta’s guide to Google PageSpeed Insights
- Browse our General Tech Accessories picks on Amazon
Discover more from TechyGeeksHome
Subscribe to get the latest posts sent to your email.
A great plugin that work perfectly. I reduced the load time to 2sec from 5sec
Due to the use of this plugin my websites speed increased amazingly. https://t.co/h04rH35zXC
Due to the use of this plugin my websites speed increased amazingly. https://t.co/h04rH35zXC
A great plugin that work perfectly. I reduced the load time to 2sec from 5sec
A great plugin that work perfectly. I reduced the load time to 2sec from 5sec