清漆,SSL和HTTP标头 - 使用SSL重新加载后没有X-Cache?

问题描述 投票:1回答:1

我注意到我的Varnish / Apache设置的一个奇怪的行为让我想知道这些页面是否在任何时候都被正确缓存。

我在端口8080上运行Apache,在同一台机器上的端口80上运行Varnish。此外,我正在使用Apache与Varnish进行SSL终止,如this article中所述

我正在测试以四种不同的方式打开网页,我希望HTTP X-Cache标头出现在所有四个实例中,以证明清漆正常运行:

  1. 使用http(端口80)调用新页面或使用强制重新加载来强制获取新副本以获取状态200正常
  2. 通过简单的重新加载在端口80(http)中再次调用同一页面以获取HTTP状态304未修改
  3. 使用https(端口443)调用页面并强制重新加载状态200 ok
  4. 使用https重新加载页面并获取状态304。

我正在使用Chrome DevTools检查标题。结果如下:

选项1:强制新页面,http

HTTP/1.1 200 OK
Date: Fri, 15 Mar 2019 22:00:10 GMT
Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/5.5.38
X-Content-Type-Options: nosniff
X-Powered-By: PHP/5.5.38
X-Drupal-Cache: MISS
Expires: Sun, 19 Nov 1978 05:00:00 GMT
Cache-Control: public, max-age=21600
X-Content-Type-Options: nosniff
Content-Language: de
X-Frame-Options: SAMEORIGIN
X-UA-Compatible: IE=edge,chrome=1
Last-Modified: Fri, 15 Mar 2019 22:00:10 GMT
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Type: text/html; charset=utf-8
X-Varnish: 323946989 325583205
Age: 2444
Via: 1.1 varnish-v4
X-Cache: HIT
X-Cache-Hits: 235
Content-Length: 39753
Connection: keep-alive
Accept-Ranges: bytes

选项2:重新加载页面,http

HTTP/1.1 304 Not Modified
Date: Fri, 15 Mar 2019 22:00:10 GMT
Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/5.5.38
X-Content-Type-Options: nosniff
X-Powered-By: PHP/5.5.38
X-Drupal-Cache: MISS
Expires: Sun, 19 Nov 1978 05:00:00 GMT
Cache-Control: public, max-age=21600
X-Content-Type-Options: nosniff
Content-Language: de
X-Frame-Options: SAMEORIGIN
X-UA-Compatible: IE=edge,chrome=1
Etag: "1552687210-1"
Last-Modified: Fri, 15 Mar 2019 22:00:10 GMT
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Type: text/html; charset=utf-8
X-Varnish: 195923610 325583205
Age: 2616
Via: 1.1 varnish-v4
X-Cache: HIT
X-Cache-Hits: 250
Connection: keep-alive

选项1:强制新页面,https

HTTP/1.1 200 OK
Date: Fri, 15 Mar 2019 22:00:10 GMT
Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/5.5.38
Expires: Sun, 19 Nov 1978 05:00:00 GMT
Cache-Control: public, max-age=21600
Vary: Accept-Encoding
X-Content-Type-Options: nosniff
X-Powered-By: PHP/5.5.38
X-Drupal-Cache: MISS
X-Content-Type-Options: nosniff
Content-Language: de
X-Frame-Options: SAMEORIGIN
X-UA-Compatible: IE=edge,chrome=1
Etag: "1552687210-1"
Last-Modified: Fri, 15 Mar 2019 22:00:10 GMT
Content-Encoding: gzip
Content-Type: text/html; charset=utf-8
X-Varnish: 482447464 325583205
Age: 1410
Via: 1.1 varnish-v4
X-Cache: HIT
X-Cache-Hits: 146
Content-Length: 39753
Accept-Ranges: bytes

选项4:页面重新加载,https

HTTP/1.1 304 Not Modified
Date: Fri, 15 Mar 2019 22:00:10 GMT
Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/5.5.38
Connection: Keep-Alive
Keep-Alive: timeout=5, max=100
Etag: "1552687210-1"
Expires: Sun, 19 Nov 1978 05:00:00 GMT
Cache-Control: public, max-age=21600
Vary: Accept-Encoding

为什么上一个请求中的标题完全不同?如何查看Varnish真正提供的页面?

apache ssl caching http-headers varnish
1个回答
1
投票

标题是不同的,因为它是一个304 http响应,这意味着文件不会再次传输并直接从您的浏览器缓存传送,因此您没有Varnish标头。我不知道为什么没有SSL的第一次重新加载有Varnish标头。

另外,你应该使用Hitch作为ssl代理,它比Apache更好,它使用the PROXY protocols有几个优点。

© www.soinside.com 2019 - 2024. All rights reserved.