NGINX does not update cache entry headers on 304 response

Ladislav Macoun ladislav.macoun at cdn77.com
Fri Jan 3 11:03:59 UTC 2020


Hello list,

NGINX currently does not update the Expires HTTP header during cache revalidation after receiving 304 response from the origin. This may lead to receiving a response from cache with invalid Expires header, and not loading content from the browser disk cache.

It looks like this behaviour is intended as Maxim states this in the commit message 
“As of now, no attempts are made to merge headers given in a 304 response during cache revalidation with headers previously stored in a cache item. Headers in a 304 response are only used to calculate new validity time of a cache item.”[1]

This behaviour seems to present until now, the cache entry only updates the file cache header. And keeps the old response headers.

This behaviour may violate the RFC for 304 Not Modified Response.

If a cache uses a received 304 response to update a cache entry, the cache MUST update the entry to reflect any new field values given in the response. [2]

As I understand this, the cache MUST update the entry fields, which in this case are only headers since origin does not resend the body.

I would like to ask if this behaviour is correct and my interpretation of the RFC is wrong, or if this behaviour is really intended or there is a bug somewhere else.

[1] https://github.com/nginx/nginx/commit/1ac2693a33bb65c6b0d777584ad8024aa743ee88
[2] https://tools.ietf.org/html/rfc2616#section-10.3.5

Yours faithfully,
Ladislav Macoun



More information about the nginx-devel mailing list