【问题标题】:HTML Page not cachingHTML页面不缓存
【发布时间】:2021-06-04 09:16:30
【问题描述】:

我已经检查了我的本地浏览器设置并且没有停止缓存(我看到同一页面中的其他几个网络请求成功加载了缓存)。每当我离开页面并返回时,总是会加载此资源(并且需要一两秒钟才能完成)。它似乎根本没有使用缓存。这是我的标题:

常规

Request URL: https://example.website.stage/htmlpage/
Request Method: GET
Status Code: 200 
Remote Address: ~omitted~
Referrer Policy: strict-origin-when-cross-origin

响应标头

alt-svc: clear
cache-control: public, max-age=43200, immutable
content-length: 68988
content-security-policy: frame-ancestors 'self'
content-type: text/html; charset=utf-8
date: Fri, 05 Mar 2021 17:01:55 GMT
server: istio-envoy
set-cookie: session_timer=session_timer; Expires=Fri, 05-Mar-2021 17:16:55 GMT; Secure; Path=/
strict-transport-security: max-age=31536000; includeSubDomains
vary: Cookie
via: 1.1 google
x-content-type-options: nosniff
x-envoy-upstream-service-time: 2618
x-frame-options: SAMEORIGIN
x-xss-protection: 1; mode=block

请求标头

:authority: example.website.stage
:method: GET
:path: /htmlpage/
:scheme: https
accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
accept-encoding: gzip, deflate, br
accept-language: en-US,en;q=0.9
cookie: ~omitted~
referer: https://example.website.stage/htmlpage
sec-ch-ua: "Chromium";v="88", "Google Chrome";v="88", ";Not A Brand";v="99"
sec-ch-ua-mobile: ?0
sec-fetch-dest: document
sec-fetch-mode: navigate
sec-fetch-site: same-origin
sec-fetch-user: ?1
upgrade-insecure-requests: 1
user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.192 Safari/537.36

【问题讨论】:

    标签: html rest web caching https


    【解决方案1】:

    想通了。如果 cookie 不匹配,响应头 vary: Cookie 会导致所有未来的请求都跳过缓存,并且由于我们的 cookie 包含时间戳,它永远不会匹配!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-28
      • 2013-05-18
      • 2020-09-15
      相关资源
      最近更新 更多