Skip to content

Commit cfa9789

Browse files
committed
[vcl] don't manually interfere with compression
Varnish already has [default compression handling](https://varnish-cache.org/docs/trunk/users-guide/compression.html#default-behaviour). This code only kicks into gear in case of a `miss` or a `pass`, and in those cases, the backend should be responsible for these.
1 parent 87d2563 commit cfa9789

File tree

3 files changed

+0
-45
lines changed

3 files changed

+0
-45
lines changed

app/code/Magento/PageCache/etc/varnish4.vcl

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -76,21 +76,6 @@ sub vcl_recv {
7676
# collect all cookies
7777
std.collect(req.http.Cookie);
7878

79-
# Compression filter. See https://www.varnish-cache.org/trac/wiki/FAQ/Compression
80-
if (req.http.Accept-Encoding) {
81-
if (req.url ~ "\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|flv)$") {
82-
# No point in compressing these
83-
unset req.http.Accept-Encoding;
84-
} elsif (req.http.Accept-Encoding ~ "gzip") {
85-
set req.http.Accept-Encoding = "gzip";
86-
} elsif (req.http.Accept-Encoding ~ "deflate" && req.http.user-agent !~ "MSIE") {
87-
set req.http.Accept-Encoding = "deflate";
88-
} else {
89-
# unknown algorithm
90-
unset req.http.Accept-Encoding;
91-
}
92-
}
93-
9479
# Remove all marketing get parameters to minimize the cache objects
9580
if (req.url ~ "(\?|&)(gclid|cx|ie|cof|siteurl|zanpid|origin|fbclid|mc_[a-z]+|utm_[a-z]+|_bta_[a-z]+)=") {
9681
set req.url = regsuball(req.url, "(gclid|cx|ie|cof|siteurl|zanpid|origin|fbclid|mc_[a-z]+|utm_[a-z]+|_bta_[a-z]+)=[-_A-z0-9+()%.]+&?", "");

app/code/Magento/PageCache/etc/varnish5.vcl

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -77,21 +77,6 @@ sub vcl_recv {
7777
# collect all cookies
7878
std.collect(req.http.Cookie);
7979

80-
# Compression filter. See https://www.varnish-cache.org/trac/wiki/FAQ/Compression
81-
if (req.http.Accept-Encoding) {
82-
if (req.url ~ "\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|flv)$") {
83-
# No point in compressing these
84-
unset req.http.Accept-Encoding;
85-
} elsif (req.http.Accept-Encoding ~ "gzip") {
86-
set req.http.Accept-Encoding = "gzip";
87-
} elsif (req.http.Accept-Encoding ~ "deflate" && req.http.user-agent !~ "MSIE") {
88-
set req.http.Accept-Encoding = "deflate";
89-
} else {
90-
# unknown algorithm
91-
unset req.http.Accept-Encoding;
92-
}
93-
}
94-
9580
# Remove all marketing get parameters to minimize the cache objects
9681
if (req.url ~ "(\?|&)(gclid|cx|ie|cof|siteurl|zanpid|origin|fbclid|mc_[a-z]+|utm_[a-z]+|_bta_[a-z]+)=") {
9782
set req.url = regsuball(req.url, "(gclid|cx|ie|cof|siteurl|zanpid|origin|fbclid|mc_[a-z]+|utm_[a-z]+|_bta_[a-z]+)=[-_A-z0-9+()%.]+&?", "");

app/code/Magento/PageCache/etc/varnish6.vcl

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -81,21 +81,6 @@ sub vcl_recv {
8181
# collect all cookies
8282
std.collect(req.http.Cookie);
8383

84-
# Compression filter. See https://www.varnish-cache.org/trac/wiki/FAQ/Compression
85-
if (req.http.Accept-Encoding) {
86-
if (req.url ~ "\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|flv)$") {
87-
# No point in compressing these
88-
unset req.http.Accept-Encoding;
89-
} elsif (req.http.Accept-Encoding ~ "gzip") {
90-
set req.http.Accept-Encoding = "gzip";
91-
} elsif (req.http.Accept-Encoding ~ "deflate" && req.http.user-agent !~ "MSIE") {
92-
set req.http.Accept-Encoding = "deflate";
93-
} else {
94-
# unknown algorithm
95-
unset req.http.Accept-Encoding;
96-
}
97-
}
98-
9984
# Remove all marketing get parameters to minimize the cache objects
10085
if (req.url ~ "(\?|&)(gclid|cx|ie|cof|siteurl|zanpid|origin|fbclid|mc_[a-z]+|utm_[a-z]+|_bta_[a-z]+)=") {
10186
set req.url = regsuball(req.url, "(gclid|cx|ie|cof|siteurl|zanpid|origin|fbclid|mc_[a-z]+|utm_[a-z]+|_bta_[a-z]+)=[-_A-z0-9+()%.]+&?", "");

0 commit comments

Comments
 (0)