When you use the add_header directive in nginx, the header is added to the response coming from the source server.
Let's say that the source server returns general cache control, max-age = 60. But in the nginx reverse proxy, you set something like:
add_header cache-control public, max-age = 10
What does it do? There are two different scenarios that I can think of:
1) Nginx looks at the cache control header from the source server and stores the contents in the cache after 60 seconds. Then it sends a response with a rewritten header, forcing the client to store the resource in the cache after 10 seconds.
or..
2) Nginx first overwrites the response headers and then interprets them. It stores the resource after 10 seconds and sends a response to the client, which also caches it after 10 seconds.
source share