Closed Slamik closed 1 month ago
Hey @Slamik , As far as remember, this is related to the cache.
When clearing the cache, if we have the same name for the old and new file, then the browser from the client will potentially have the older version of that asset cached. Then it will use it instead of the new version, which would potentially break some functionality or layout on the page.
As far as remember, this is related to the cache. Yes, that's correct. https://github.com/wp-media/wp-rocket/blob/7999ed2618d11d7fa9b63fc78a7810789072d4b9/inc/Engine/Optimization/AbstractOptimization.php#L235
But you have to agree, it's rather strange to remove the "?ver" in the basic functionality for optimization purposes and then add a version for the cache with no way to disable it. It would be great to at least have the ability to disable this through a hook.
protected function get_full_minified_url( $minified_path, $minified_url ) {
// Apply filter to allow disabling the query string
$add_query_string = apply_filters( 'rocket_add_minified_version_query_string', true, $minified_url );
if ( ! $add_query_string ) {
return $minified_url;
}
$file_mtime = rocket_direct_filesystem()->mtime( $minified_path );
$version = $file_mtime ? $file_mtime : md5( $minified_url . $this->minify_key );
return add_query_arg( 'ver', $version, $minified_url );
}
add_filter( 'rocket_add_minified_version_query_string', '__return_false' );
add_filter( 'rocket_add_minified_version_query_string', function( $add_version, $url ) {
if ( strpos( $url, 'specific-file.css' ) !== false ) {
return false;
}
return $add_version;
}, 10, 2 );
I agree with @CrochetFeve0251
Hello @Slamik, To avoid adding ver
query string you could disable the minification setting, since nowadays it has a minimap impact on the performance. In general, we can not deactivate it by default for all customers. If you'd like to have a filter for your specific use case, feel free to open a PR and reopen the issue. Unfortunately, we'll not be able to work on this in the upcoming months.
Hello, I would like to inquire if there is any point in adding "ver" to all cached .css files? Googlebot is going crazy and scanning all possible "?ver=" of styles.