I’m potentially being stupid here, but I’m new to Fastly and VCL, and I’m trying to cache my site, but nothing seems to be caching.
My site runs on MediaWiki, and it sends the “Accept-Encoding, Cookie, Authorization” header, which is the default for MediaWiki. I’ve removed the Authorization header in the VCL, but kept the Cookie and the Accept-Encoding header, but my site doesn’t seem to be caching still, it seems to always miss.
If I remove the “Cookie” from the vary header, then it caches properly, but obviously this isn’t ideal and I don’t want to remove the cookie header if possible because then users won’t be able to log in (and I see other websites also running on Fastly that don’t remove the Cookie vary and it still caches; is there anything I can do to force it to cache without removing the “cookie” from vary? This is my VCL. I’ve set the cache to pass to the origin if the “[sS]ession” or “Token” cookies are set which signifies a log in and nothing should be cached.
Any help appreciated! I’ve also put below the headers that appear when a cache miss occurs.
Cache-Control: public, max-age=3600
Content-Language: en
Content-Length: 88506
Content-Type: text/html; charset=UTF-8
Date: Thu, 12 Oct 2023 21:04:23 GMT
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Last-Modified: Thu, 12 Oct 2023 20:59:29 GMT
Server: Apache
Vary: Accept-Encoding, Cookie
Via: 1.1 varnish
X-Cache: MISS
This is an example of another website that also uses Fastly, and caches despite the cookie vary:
HTTP/2 200
content-type: text/html; charset=UTF-8
x-content-type-options: nosniff
content-language: en
content-security-policy: upgrade-insecure-requests
last-modified: Wed, 11 Oct 2023 09:44:43 GMT
x-request-id: 075e1ac910e2364e473fbe45f4604f56
content-encoding: br
x-envoy-upstream-service-time: 106
x-datacenter: SJC
x-cacheable: YES
accept-ranges: bytes
date: Thu, 12 Oct 2023 21:09:19 GMT
age: 41076
x-served-by: cache-wk-sjc11420-SJC, cache-lcy-eglc8600051-LCY
x-cache: HIT, HIT
x-cache-hits: 5, 2
x-timer: S1697144960.646185,VS0,VE0
vary: Accept-Encoding, Cookie
cache-control: private, s-maxage=0, max-age=0, must-revalidate
content-length: 38029
X-Firefox-Spdy: h2
Can anyone point me in the right direction of what I can possibly do here?