0
votes

Given a nodejs application with express, which goes through nginx. I'm trying to add cache support with etags.

Without nginx, if the application get called directly it works. I set the If-None-Match Header and receive a 304.

With nginx, the response is always 200.

My Nginx config:

    location /app/ {
            proxy_pass http://app;
    }

Log entry from express.

info: HTTP GET /app/ statusCode=200, url=/app/, connection=upgrade, host=11.1.1.1, accept=application/json, text/plain, /, user-agent=Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36, referer=somesite.com, accept-language=en-US,en;q=0.8,de;q=0.6,
if-none-match=W/"29ae92-4sHBxs6sPcMB3/GypUtubLN0HQ8-gzip", x-forwarded-proto=http, cookie=io=XAMR4ZH1TzxIvWzkAAAA, x-forwarded-for=10.43.212.26, x-forwarded-host=somesite.com, x-forwarded-server=somesite.com, method=GET, httpVersion=1.1, originalUrl=/app/, responseTime=352

1

1 Answers

0
votes

You should enable HTTP/1.1 in the NGINX configuration:

location /app/ {
  proxy_http_version 1.1;
  proxy_pass http://app;
}