I'm using Django with Varnish 4.
I'm trying to achieve that:
- If the request is not for the home page, pass (I'm trying to only cache the home page at the moment to test it, etc.)
- If the cookie 'sessionid' is present, pass or cache for each sessions
- Anything else: pass
Here's the configuration of sub vcl_recv:
# cache only home page
if (! req.url == "/") {
return(pass);
}
# not caching if cookie sessionid is present
if (req.http.Cookie ~ "sessionid") {
return(pass);
}
unset req.http.cookie;
So far, Varnish seems to always generate a new page for each it when calling the home page as anonymous. I can tell using the headers Varnish send (the 'age' is always 0 and 'X-Varnish' is always a different number).
It's either that my configuration is missing something, or is it because Django sends a 'Vary: Cookie' in the response? If it's the case, how can I 'hide' cookies from Varnish in this case (only for anonymous users)?