Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend surrogate keys instead of replacing them #719

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
32 changes: 23 additions & 9 deletions etc/vcl_snippets/fetch.vcl
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,30 @@
if (beresp.ttl > 0s && (req.request == "GET" || req.request == "HEAD") && !req.http.x-pass ) {
unset beresp.http.set-cookie;

# init surrogate keys
if (beresp.http.X-Magento-Tags) {
set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags " text";
} else {
set beresp.http.Surrogate-Key = "text";
}
# init surrogate keys if on outermost node
if (fastly.ff.visits_this_service == 0 && req.restarts == 0) {
if (beresp.http.X-Magento-Tags) {
if (beresp.http.Surrogate-Key) {
set beresp.http.Surrogate-Key = beresp.http.Surrogate-Key " " beresp.http.X-Magento-Tags " text";
} else {
set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags " text";
}
} else {
if (beresp.http.Surrogate-Key) {
set beresp.http.Surrogate-Key = beresp.http.Surrogate-Key " text";
} else {
set beresp.http.Surrogate-Key = "text";
}
}

# set surrogate keys by content type if they are image/script or CSS
if (beresp.http.Content-Type ~ "(image|script|css)") {
set beresp.http.Surrogate-Key = re.group.1;
# set surrogate keys by content type if they are image/script or CSS
if (beresp.http.Content-Type ~ "(image|script|css)") {
if (beresp.http.Surrogate-Key) {
set beresp.http.Surrogate-Key = beresp.http.Surrogate-Key " " re.group.1;
} else {
set beresp.http.Surrogate-Key = re.group.1;
}
}
}
}

Expand Down