varnish not work only for one web site

81 views Asked by At

I have a server with more site , after install varnish I tested if cache works, but for one web site not work varnish (have response of max-age=0). If I try to insert a simple php page (not correlated to main website) in same folder of this website, the response works.

This is a header when try :

HTTP/1.1 200 OK
Server: Apache/2.2.27 (Unix) mod_ssl/2.2.27 OpenSSL/1.0.1e-fips
X-Powered-By:   PHP/5.2.17
Set-Cookie: PHPSESSID=ragejao4sm1kckjn1trvap3ft0; path=/
Vary:   User-Agent,Accept-Encoding
Content-Encoding:   gzip
Content-Type:   text/html
Cache-Control:  max_age=8600
magicmarker:    1
Content-Length: 11863
Accept-Ranges:  bytes
Date:   Fri, 12 Jun 2015 12:28:15 GMT
X-Varnish:  1250916100
Age:    0
Via:    1.1 varnish
Connection: keep-alive
1

There are 1 answers

1
Stephen On

Varnish by default doesn't cache responses where cookies are set.

If you want to change this behaviour you need to consider how the cookie is being used (it looks like a session cookie) and either use the session id as part of the cache hash (ie so other users don't get a cached response from someone else's session) or use something like ESI to allow the "common" parts of the page to be cached while the session specific parts are fetched independently.

http://www.varnish-cache.org/trac/wiki/VCLExampleCacheCookies

https://www.varnish-cache.org/trac/wiki/ESIfeatures