Score:0

HTTP_IF_NONE_MATCH Missing on Server Side with Chrome Requests to NGINX

ke flag

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.

Gerard H. Pille avatar
in flag
Use tcpdump to find out who dumps it, Nginx or Apache. Did you tell Nginx to pass it through? Oh, and why do you put a reverse proxy in front of a reverse proxy?
ke flag
@GerardH.Pille I don't really have any experience with tcpdump -- is there a good recommendation you could give me re: flags for watching this? As to NGINX, it is serving the static content for the site, while I'm using Apache to spawn FastCGI processes for Perl. I've run into some issues trying to get FastCGI to spawn properly directly under NGINX.
Gerard H. Pille avatar
in flag
In which case you should have let Apache deal with the static content too - but I'm quite sure Nginx could have handled all you need. Have a look at the examples in tcpdump's manual page. IIRC, I'd run a "tcpdump -A -s0" on the port on which Apache is listening, to see if the "if-none-match" is still there. But: "Did you tell Nginx to pass it through?"
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.