Let me explain with an example:
File: /etc/varnish/default.vcl
# [...]
sub vcl_recv {
# [...]
if (req.request != "GET" && req.request != "HEAD") {
return (pass);
}
if (req.http.Authorization || req.http.Authenticate) {
return (pass);
}
if (req.url ~ "wp-(login|admin|comments-post.php|cron.php)") {
return (pass);
}
# [...]
return (lookup);
}
sub vcl_fetch {
# [...]
if (req.request != "GET" && req.request != "HEAD") {
return (hit_for_pass);
}
if (req.http.Authorization || req.http.Authenticate) {
return (hit_for_pass);
}
if (req.url ~ "wp-(login|admin|comments-post.php|cron.php)") {
return (hit_for_pass);
}
# [...]
return (deliver);
}
As you can see, for content that shouldn't be cached, I have same policies under vcl_recv
and vcl_fetch
but with return (pass);
and return (hit_for_pass);
respectively.
There are some cases when this should be done (when it is useful), and others where this is absolutely unnecessary. What are they? (e.g. Cookies? If so, how?)