Support ESI with clustering

Previously, we failed to support ESI correctly: The fetch node would
run ESI on the client side, such that the delivery node would receive
an already ESI processed object.

The concept of this change is:

Custom code on the fetch node decides on beresp.do_esi. vcl_deliver on
the fetch node sets the "E" bit of a new flags header if obj.can_esi
is true, which reflects beresp.do_esi and disables ESI processing.

When the delivery node receives an object from the fetch nodes, it
sets beresp.do_esi based on the flags header.

Ultimately, beresp.do_esi == obj.can_esi is identical on the fetch and
delivery nodes.
parent dc9d0dcd
......@@ -209,6 +209,9 @@ sub vcl_backend_response {
else {
set beresp.uncacheable = true;
}
if (beresp.http.VK8S-Cluster-Flags ~ "^E") {
set beresp.do_esi = true;
}
return (deliver);
}
}
......@@ -221,12 +224,17 @@ sub vcl_backend_error {
sub vcl_deliver {
unset resp.http.VK8S-Cluster-TTL;
unset resp.http.VK8S-Cluster-Flags;
if (remote.ip ~ vk8s_cluster_acl
{{- if hasPrimary . }} && ! vk8s_cluster_primary.defined()
{{- end }}) {
if (! obj.uncacheable) {
set resp.http.VK8S-Cluster-TTL = obj.ttl;
}
if (obj.can_esi) {
set resp.http.VK8S-Cluster-Flags = "E";
}
set resp.do_esi = false;
return (deliver);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment