1 # Example VCL for Varnish 4.0 with public-inbox WWW code
2 # This is based on what shipped for 3.x a long time ago (I think)
3 # and I'm hardly an expert in VCL (nor should we expect anybody
4 # who maintains a public-inbox HTTP interface to be).
6 # It seems to work for providing some protection from traffic
7 # bursts; but perhaps the public-inbox WWW interface can someday
8 # provide enough out-of-the-box performance that configuration
9 # of an extra component is pointless.
18 if (req.restarts == 0) {
19 if (req.http.x-forwarded-for) {
20 set req.http.X-Forwarded-For =
21 req.http.X-Forwarded-For + ", " + client.ip;
23 set req.http.X-Forwarded-For = client.ip;
26 if (req.method != "GET" &&
27 req.method != "HEAD" &&
28 req.method != "PUT" &&
29 req.method != "POST" &&
30 req.method != "TRACE" &&
31 req.method != "OPTIONS" &&
32 req.method != "DELETE") {
33 /* Non-RFC2616 or CONNECT which is weird. */
36 if (req.method != "GET" && req.method != "HEAD") {
37 /* We only deal with GET and HEAD by default */
40 if (req.http.Authorization || req.http.Cookie) {
41 /* Not cacheable by default */
50 hash_data(req.http.host);
54 if (req.http.X-Forwarded-Proto) {
55 hash_data(req.http.X-Forwarded-Proto);
60 sub vcl_backend_response {
61 set beresp.grace = 60s;
62 set beresp.do_stream = true;
63 if (beresp.ttl <= 0s ||
64 beresp.http.Set-Cookie ||
65 beresp.http.Vary == "*") {
66 /* Mark as "Hit-For-Pass" for the next 2 minutes */
67 set beresp.ttl = 120 s;
68 set beresp.uncacheable = true;