Skip to content

Commit 53d39a3

Browse files
authored
ENGCOM-4568: [Backport] Remove all marketing get params on Varnish to minimize the cache objects #21819
2 parents 571a7c4 + d0f568f commit 53d39a3

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,11 @@ sub vcl_recv {
9191
}
9292
}
9393

94-
# Remove Google gclid parameters to minimize the cache objects
95-
set req.url = regsuball(req.url,"\?gclid=[^&]+$",""); # strips when QS = "?gclid=AAA"
96-
set req.url = regsuball(req.url,"\?gclid=[^&]+&","?"); # strips when QS = "?gclid=AAA&foo=bar"
97-
set req.url = regsuball(req.url,"&gclid=[^&]+",""); # strips when QS = "?foo=bar&gclid=AAA" or QS = "?foo=bar&gclid=AAA&bar=baz"
94+
# Remove all marketing get parameters to minimize the cache objects
95+
if (req.url ~ "(\?|&)(gclid|cx|ie|cof|siteurl|zanpid|origin|mc_[a-z]+|utm_[a-z]+)=") {
96+
set req.url = regsuball(req.url, "(gclid|cx|ie|cof|siteurl|zanpid|origin|mc_[a-z]+|utm_[a-z]+)=[-_A-z0-9+()%.]+&?", "");
97+
set req.url = regsub(req.url, "[?|&]+$", "");
98+
}
9899

99100
# Static files caching
100101
if (req.url ~ "^/(pub/)?(media|static)/") {

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,11 @@ sub vcl_recv {
9292
}
9393
}
9494

95-
# Remove Google gclid parameters to minimize the cache objects
96-
set req.url = regsuball(req.url,"\?gclid=[^&]+$",""); # strips when QS = "?gclid=AAA"
97-
set req.url = regsuball(req.url,"\?gclid=[^&]+&","?"); # strips when QS = "?gclid=AAA&foo=bar"
98-
set req.url = regsuball(req.url,"&gclid=[^&]+",""); # strips when QS = "?foo=bar&gclid=AAA" or QS = "?foo=bar&gclid=AAA&bar=baz"
95+
# Remove all marketing get parameters to minimize the cache objects
96+
if (req.url ~ "(\?|&)(gclid|cx|ie|cof|siteurl|zanpid|origin|mc_[a-z]+|utm_[a-z]+)=") {
97+
set req.url = regsuball(req.url, "(gclid|cx|ie|cof|siteurl|zanpid|origin|mc_[a-z]+|utm_[a-z]+)=[-_A-z0-9+()%.]+&?", "");
98+
set req.url = regsub(req.url, "[?|&]+$", "");
99+
}
99100

100101
# Static files caching
101102
if (req.url ~ "^/(pub/)?(media|static)/") {

0 commit comments

Comments
 (0)