vcl 4.1; backend default { .path = "{{ varnish.backend.sock }}"; .max_connections = 300; .first_byte_timeout = 240s; .connect_timeout = 10s; .between_bytes_timeout = 2s; } sub vcl_recv { unset req.http.user-agent; if ( req.method != "GET" && req.method != "HEAD" && req.method != "PUT" && req.method != "POST" && req.method != "TRACE" && req.method != "OPTIONS" && req.method != "PATCH" && req.method != "DELETE") { return (pipe); } if (req.http.Upgrade ~ "(?i)websocket") { return (pipe); } if (req.http.range) { return (pass); } if (req.method == "GET" || req.method == "HEAD") { return (hash); } return (pass); } sub vcl_hash { hash_data(req.url); hash_data(req.http.host); if (req.http.cookie) { hash_data(req.http.cookie); } return (lookup); } sub vcl_hit { return (deliver); } sub vcl_miss { return (fetch); } sub vcl_pipe { if (req.http.upgrade) { set bereq.http.upgrade = req.http.upgrade; } return (pipe); } sub vcl_backend_response { if (beresp.http.Cache-Control ~ "private") { return (pass); } if (beresp.http.ETag || beresp.http.Last-Modified) { set beresp.keep = 4h; } if (beresp.status == 301) { set beresp.ttl = 24h; } return (deliver); }