简体   繁体   中英

Varnish won't cache - Age 0

I seem to be having some problems with my Varnish set up. I have a clean install of Varnish and Nginx running on ubuntu, everything seems to be running, but I don't seem to be actually caching anything.

This is what im seeing:

HTTP/1.1 200 OK
Server: nginx/1.4.6 (Ubuntu)
Content-Type:   text/html; charset=UTF-8
Vary:   Accept-Encoding
X-Powered-By:   PHP/5.5.9-1ubuntu4.14
Cache-Control:  no-cache
Date:   Tue, 02 Feb 2016 10:15:17 GMT
Content-Encoding:   gzip
X-Varnish:  196655
Age:    0
Via:    1.1 varnish-v4
Accept-Ranges:  bytes
Connection: keep-alive

I'm almost certain the problem is to do with the "age" response being 0. I have read that the Cache-Control header can be the culprit and have spent some time configuring both nginx and my vcl file with solutions I have read on-line, none of which have worked.

I'm open to any ideas even ones I have tried before (hence why im not listing the steps I have already taken).

Thanks in advance for any thoughts you might have.

Remove "no-cache" and set "max-age=120" (in seconds) in the Cache-Control header instead.

Also note that if the request contains any cookies or if the response sets any cookies than by default varnish is not gonna cache.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM