Skip to content

Commit f0acee2

Browse files
authored
Merge pull request #338 from fastly/vcl_x_compress_hint
Due to changes how Fastly terminates TLS traffic we need to make sure…
2 parents 3340e3e + 0056eac commit f0acee2

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

Diff for: etc/vcl_snippets/deliver.vcl

+6-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
if ( fastly.ff.visits_this_service == 0 ) {
88
# Remove X-Magento-Vary and HTTPs Vary served to the user
99
set resp.http.Vary = regsub(resp.http.Vary, "(?i)X-Magento-Vary,Https", "Cookie");
10+
# Since varnish doesn't compress ESIs we need to hint to the HTTP/2 terminators to
11+
# compress it and we only want to do this on the edge nodes
12+
if (resp.http.x-esi) {
13+
set resp.http.x-compress-hint = "on";
14+
}
1015
remove resp.http.X-Magento-Tags;
1116
}
1217

@@ -18,7 +23,7 @@
1823
remove resp.http.fastly-page-cacheable;
1924
}
2025

21-
# debug info
26+
# X-Magento-Debug header is exposed when developer mode is activated in Magento
2227
if (!resp.http.X-Magento-Debug) {
2328
# remove Varnish/proxy header
2429
remove resp.http.X-Magento-Debug;

Diff for: etc/vcl_snippets/fetch.vcl

+1-8
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,12 @@
4040
if (beresp.http.x-esi) {
4141
# enable ESI feature for Magento response by default
4242
esi;
43-
# Since varnish doesn't compress ESIs we need to hint to the HTTP/2 terminators to
44-
# compress it
45-
set beresp.http.x-compress-hint = "on";
4643
} else {
4744
# enable gzip for all static content except
4845
if ( http_status_matches(beresp.status, "200,404") && (beresp.http.content-type ~ "^(application\/x\-javascript|text\/css|text\/html|application\/javascript|text\/javascript|application\/json|application\/vnd\.ms\-fontobject|application\/x\-font\-opentype|application\/x\-font\-truetype|application\/x\-font\-ttf|application\/xml|font\/eot|font\/opentype|font\/otf|image\/svg\+xml|image\/vnd\.microsoft\.icon|text\/plain)\s*($|;)" || req.url.ext ~ "(?i)(css|js|html|eot|ico|otf|ttf|json)" ) ) {
4946
# always set vary to make sure uncompressed versions dont always win
5047
if (!beresp.http.Vary ~ "Accept-Encoding") {
51-
if (beresp.http.Vary) {
52-
set beresp.http.Vary = beresp.http.Vary ", Accept-Encoding";
53-
} else {
54-
set beresp.http.Vary = "Accept-Encoding";
55-
}
48+
set beresp.http.Vary:Accept-Encoding = "";
5649
}
5750
if (req.http.Accept-Encoding == "gzip") {
5851
set beresp.gzip = true;

0 commit comments

Comments
 (0)