Search code examples
htmlrestwebcachinghttps

HTML Page not caching


I already checked my local browser settings and nothing is stopping caching (I see several other network requests in the same page load that cache successfully). Whenever I navigate away from the page and back, this resource always loads (and takes a second or two to do so). It doesn't appear to be using the cache at all. Here are my headers:

General

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

Response Headers

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

Request Headers

: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

Solution

  • Figured it out. The response header vary: Cookie causes all future requests to be skip the cache if the cookie doesn't match, and since our cookie contains a timestamp, it'll never match!