Closed superpoincare closed 6 months ago
Hello @superpoincare
The code uses one or the other.
/**
* Set Accept-Encoding
*/
if ( $config->get_boolean( 'browsercache.enabled' ) && $config->get_boolean( 'browsercache.html.brotli' ) ) {
$rules .= " RewriteCond %{HTTP:Accept-Encoding} br\n";
You can try adding this below the existing lines:
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteRule .* - [E=W3TC_ENC:_gzip]
So it will look like this:
RewriteCond %{HTTP:Accept-Encoding} br
RewriteRule .* - [E=W3TC_ENC:_br]
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteRule .* - [E=W3TC_ENC:_gzip]
If this works you can try removing the word "else" from that line in wp-content/plugins/w3-total-cache/PgCache_Environment.php#L697
diff --git a/PgCache_Environment.php b/PgCache_Environment.php
index 7342a188..0d2c488f 100644
--- a/PgCache_Environment.php
+++ b/PgCache_Environment.php
@@ -694,7 +694,8 @@ class PgCache_Environment {
$rules .= " RewriteCond %{HTTP:Accept-Encoding} br\n";
$rules .= " RewriteRule .* - [E=W3TC_ENC:_br]\n";
$env_W3TC_ENC = '%{ENV:W3TC_ENC}';
- } else if ( $config->get_boolean( 'browsercache.enabled' ) && $config->get_boolean( 'browsercache.html.compression' ) ) {
+ }
+ if ( $config->get_boolean( 'browsercache.enabled' ) && $config->get_boolean( 'browsercache.html.compression' ) ) {
Please let me know if this helps!
Thanks!
Hi @mavas84
Will try the fix.
The htaccess rule suggested may not work because browsers which accept both brotli and gzip have both of them in the Accept-Encoding header.
So the second RewriteCond rule would need some modification to check if br is not present in the header.
Otherwise brotli browsers will get gzip.
If brotli is available, this is the rule I get in
.htaccess
This leaves out the case where "Accept-Encoding: br ... " isn't there in Request Headers, just gzip and deflate. In the case where browser doesn't accept brotli, non-gzipped file is sent.
The rules in the minify directory look fine and allow for both cases.
So need to add allow rules for gzip.