I am trying to understand the behavior of varnish and was hoping that someone could shed some light.
I am doing a test where I am trying to make a varnish for caching requests / responses using cookies.
I have a very simple PHP script, it just starts the session.
<?php session_start(); ?>
I expect the varnish will not cache from Set-Cookie and Cookie headers .
I will leave and turn off these headers:
sub vcl_backend_response {
unset beresp.http.set-cookie;
}
sub vcl_recv {
unset req.http.cookie;
}
The requested page is still not cached .
I know that PHP will send cache headers that can be respected by varnish. Let check:
<?php echo session_cache_limiter(); ?>
Output: nocache
From session_cache_limiter (), the documentation is known for nocache sending these responce headers to overload the cache:
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
:
sub vcl_backend_response {
unset beresp.http.expires;
unset beresp.http.pragma;
unset beresp.http.cache-control;
unset beresp.http.set-cookie;
}
, , .
, , - ttl:
sub vcl_backend_response {
unset beresp.http.expires;
unset beresp.http.pragma;
unset beresp.http.cache-control;
unset beresp.http.set-cookie;
set beresp.ttl = 10m;
}
:
TTL , 2m (-t 120 CLI ), ?
/usr/sbin/varnishd -P /var/run/varnish.pid -f /etc/varnish/default.vcl -a :80 -T 0.0.0.0:6082 -t 120 -u varnish -g varnish -S /etc/varnish/secret -s malloc,512M
- ? , TTL ( )?