Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
director routing_mesh round-robin {
{
.backend = {
.host = "...some ip...";
.port = "...some port...";
.first_byte_timeout = 90s;
.between_bytes_timeout = 90s;
}
# ...more backends...
}
}
sub vcl_recv {
set req.backend = routing_mesh;
# POST, PUT, and DELETE are not cached
if (req.request != "GET" && req.request != "HEAD") {
return (pass);
}
# never cache when http basic auth is used
if (req.http.Authorization) {
return (pass);
}
# serve stale items for 30 seconds while fetching new item from backend
set req.grace = 30s;
return (lookup);
}
sub vcl_fetch {
# cache 200s set to cache public
if (obj.cacheable && obj.http.Cache-Control ~ "public") {
set obj.prefetch = -30s;
unset obj.http.set-cookie;
return (deliver);
}
# everything else is served dynamically
return (pass);
}
sub vcl_error {
set obj.http.Content-Type = "text/html; charset=utf-8";
synthetic {"...error page html..."};
return (deliver);
}
# Disable keep-alive support with backends
sub vcl_miss {
set bereq.http.Connection = "close";
}
sub vcl_pass {
set bereq.http.Connection = "close";
}
sub vcl_pipe {
set bereq.http.Connection = "close";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.