I want to use Varnish to cache certain pages even in the presence of cookies. There are 3 possibilities that I need to take care of:
- An anonymous user is viewing some page
- A logged in user is viewing some page with light customization. These customizations are all stored in a signed-cookie and are dynamically populated by Javascript. The vary-cookie http header is not set.
- A logged in user is viewing some page with customized data from the database. The vary-cookie http header is set.
The expected behaviors would be:
- Cache the page. This is the most basic scenario for Varnish to handle.
- Cache the page and do not delete the cookie because some Javascript logic needs it.
- Never cache this page because vary-cookie is signalling the cookie contents will affect the output of this page.
I have read some docs on Varnish and I cannot tell if this is the default behavior or if there is some setup I have to do in VCL to make it happen.