I have an issue with my Word-press site, When i tested with GTmetrix it is saying Serve resources from a consistent URL. and it showing that i have used 2 css files one with normal correct extension .css and another one with some version extension as last which is .css?ver=4.9.8. The correct one is the first one style.css. i do not know from where the other one is coming. I have not used anywhere in my knowledge. I have tried de-activating some plugins like cache from admin panel as per Google recommendations. But it does not work. https://gtmetrix.com/reports/pentaworkspace.com/z0ra5DhP
Please anyone help me on this?
This CSS file is certainly queued by your theme. The code should be around function.php
or related file. Try a search for wp_enqueue_script
, and look for your problematic script name passed as a parameter.
The version parameter in the URL is here to be able to clear browser cache: if your file is updated, but URL doesn't change: the browser will keep using his cached version and won't have updates displayed. Updating this ver
parameter will force a browser to download and cache the file again.
You can use a snippet like this to remove those parameters (now that you know why they are here, and what situation it can generate):
function remove_wp_assets_qvar( $src ) {
$src = preg_replace_callback( '/ver=[^&]*/', __NAMESPACE__ . '\\removeVersionCallback', $src );
if ( strpos( $src, 'ver=' ) ) {
$src = remove_query_arg( 'ver', $src );
}
return $src;
}
add_filter( 'style_loader_src', __NAMESPACE__ . '\\remove_wp_assets_qvar', 9999 );
add_filter( 'script_loader_src', __NAMESPACE__ . '\\remove_wp_assets_qvar', 9999 );
Infos: nowadays, a lot of assets pipeline (webpack, gulp...) are generating "versioned" build files with a unique hash in the filename to prevent those browser caching "issues".