If you’ve ever tested you WordPress website on gtmetrix you may have seen “Remove query strings from static resources” in the results. These query strings can stop these assets from being cached.
Most proxies, most notably Squid up through version 3.0, do not cache resources with a “?” in their URL. To enable proxy caching for these resources, remove query strings from references to static resources, and instead encode the parameters into the file names themselves.
This snippet will remove query strings from static urls in WordPress, just place this in your functions.php file within your theme directory.
function _remove_script_version( $src ){
$parts = explode( '?ver', $src );
return $parts[0];
}
add_filter( 'script_loader_src', '_remove_script_version', 15, 1 );
add_filter( 'style_loader_src', '_remove_script_version', 15, 1 );