/*
* First, set up a backend to answer the request if there's not a cache hit.
*/
backend default {
.host = "host.hr";
.port = "8080";
}
backend adserve {
.host = "adserve.host.hr";
.port = "8080";
}
/*
* "receive" subroutine.
*/
sub vcl_recv {
# Use the backend we set up above to answer the request if it's not cached.
set req.backend = default;
# pass adserve
if (req.http.host == "adserve.host.hr") {
set req.backend = adserve;
return (pass);
}
# exclude POST requests (on order for search to work).
if (req.request == "POST") {
ban("req.url == " + req.url);
set req.http.X-Test = req.url;
return (pass);
}
# fully exclude admin from caching, it could be pass, but since I had problems with sessions, I've tried pipe, still didn't fix the issue with random logouts, but it works
if (req.url ~ "^/admin(.*)") {
return(pipe);
} else {
return(lookup);
}
}
sub vcl_miss {
return(fetch);
}
sub vcl_hit {
return(deliver);
}
/*
* This is the subroutine which will fetch a response from the backend.
*/
sub vcl_fetch {
# lets try to modify cache control and see how it goes.
set beresp.http.Cache-Control = "private, max-age=30, must-revalidate";
# Get the response. Set the cache lifetime of the response to 20 secs.
set beresp.ttl = 20s;
# Indicate that this response is cacheable. This is important.
set beresp.http.X-Cacheable = "YES";
unset beresp.http.Vary;
return(deliver);
}
/*
* PIPE FIX for return(pipe) for admin.
*/
sub vcl_pipe {
# This forces every pipe request to be the first one.
set bereq.http.connection = "close";
}
sub vcl_deliver {
return(deliver);
}
It looks like you're new here. If you want to get involved, click one of these buttons!