Replies: 3
Hi,
I’m back with another bug report that I was able to finally trace in W3-total-cache.
The problem occurs when in W3TC settings -> Browser cache -> CSS/JS -> “Prevent caching of objects after settings change” is turned on. Instead of appending the ?xNNNN cache bust value to the urls, it incorrectly overrides and erases the ?ver= parameter entirely.
For example,
<script type='text/javascript' src='http://SITE/wp-content/themes/THEME/js/example.js?ver=4.7.2'></script>
becomes
<script type='text/javascript' src='http://SITE/wp-content/themes/THEME/js/example.js?x41610'></script>
instead of
<script type='text/javascript' src='http://SITE/wp-content/themes/THEME/js/example.js?ver=4.7.2&x41610'></script>
This means that the cache will only be busted when new W3TC settings are saved rather than when the WP version or file version changes.
The bug in W3TC 0.9.5.2 is here:
$test_url = Util_Environment::remove_query( $url );
on line 215 of BrowserCache_Plugin.php
In turn:
static public function remove_query( $url ) {
$url = preg_replace( '~[&\?]+(ver=([a-z0-9-_\.]+|[0-9-]+))~i', '', $url );
return $url;
}
is on line 837 of Util_Environment.php.
As you can see, it empties out ver= for some reason, which is incorrect behavior.
Can we hope for a fix? I’d like to keep this setting enabled, but for now I’m forced to turn it off.
-
This topic was modified 12 hours, 15 minutes ago by
archon810.