I see indications that this should work, so I'm hoping I'm missing something simple.
We have two nginx "servers", a proxy_pass cache in front and an SSI server behind it. If I go directly to the SSI server with an If-Modified-Since header in the request, it will return a 304-Not Modified response just fine, which is what we want. But I cannot get the proxy_pass cache server to return a 304-Not Modified for anything.
Should I be able to get the proxy_pass to return a 304-Not Modified? Does anyone else have it working with a config you could share? Or can you spot the problem in my config?
# this is the cache in front server { listen 8096; server_name _; proxy_buffering on; location /assets { proxy_pass http://localhost:8095; proxy_cache my-cache; proxy_cache_valid 200s; if_modified_since before; } } server { listen 8095; server_name _; root /var/www/; location / { deny all; } location /assets {} ssi on; # on or off doesn't make a difference to the front-end cache behavior if_modified_since before; } } # here's the base config, fwiw: proxy_buffering on; proxy_cache_valid any 10m; proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=my-cache:8m max_size=3000m inactive=24h; proxy_temp_path /var/cache/nginx/tmp; proxy_buffer_size 4k; proxy_buffers 100 8k;  Thanks.
proxy_cacheenabled, the request will not be proxied to the upstream server when the cache is hit. However, in order for your upstream server to return a 304, you'll want to send the if_modified_since header along with the request. Try outproxy_set_header If-Modified-Since $http_if_modified_since.