I'm trying to add etag
based cache verification to a web app I've developed that runs on Apache via an NGINX reverse proxy. The web app is written in Perl. In the Perl script, I check for the $ENV{'HTTP_IF_NONE_MATCH'}
header and then test the etag
in it, if it exists. If I access the app via cURL, it works:
timothybutler@timothys-MacBook-Pro ~ % curl -I https://server/resource/podcast/20211101.mp3
HTTP/1.1 200 OK
Server: nginx/1.21.4
Date: Fri, 12 Nov 2021 18:06:37 GMT
Content-Type: audio/mpeg
Content-Length: 16665729
Connection: keep-alive
Surrogate-Control: no-cache
Cache-Control: private,max-age=864000
Etag: "1635825322"
Giving that etag
back via cURL, I get the expected result:
timothybutler@timothys-MacBook-Pro ~ % curl -H 'If-None-Match: "1635825322"' -I https://server/resource/podcast/20211101.mp3
HTTP/1.1 304 Not Modified
Server: nginx/1.21.4
Date: Fri, 12 Nov 2021 18:19:29 GMT
Connection: keep-alive
Cache-Control: private, max-age=864000
Etag: "1635825322"
However, the process breaks down if I try it in Chrome instead. Chrome reports sending If-None-Match: "1635825322"
as one of the headers when I refresh the page, but my server does not set the HTTP_IF_NONE_MATCH
environmental variable for that request contrary to the one that came in via cURL. If I dump all of the %ENV hash, the If-Match-None
header and its etag
is simply not present in any form when Chrome issues the request.
0 Answers