Haproxy 会话保持返回Cache-control

Haproxy 开启会话保持

$ curl 180.150.186.213 -I 
HTTP/1.1 200 OK  
Server: nginx/1.0.15  
Date: Tue, 12 Apr 2016 10:22:36 GMT  
Content-Type: text/html  
Content-Length: 3698  
Last-Modified: Tue, 16 Jun 2015 21:34:15 GMT  
Accept-Ranges: bytes  
Set-Cookie: SERVER_ID=b084c405-b93dcf95; path=/  
Cache-control: private  

为什么在响应头中返回了Cache-control: private

查看haproxy配置发现

cookie SERVER_ID insert indirect nocache  

其中nocache禁止中间代理缓存本次响应,因为响应头中有Set-Cookie,不应该被缓存

当带会话保持cookie访问就不会返回Cache-control

$ curl 180.150.186.213 -I -H "Cookie: SERVER_ID=b084c405-b93dcf95"
HTTP/1.1 200 OK  
Server: nginx/1.0.15  
Date: Tue, 12 Apr 2016 10:41:11 GMT  
Content-Type: text/html  
Content-Length: 3698  
Last-Modified: Tue, 16 Jun 2015 21:34:15 GMT  
Accept-Ranges: bytes