How to adjust Cache-Control for SSI-including entities
jan.algermissen at nordsc.com
Mon Jan 19 19:44:33 UTC 2015
[apologies if this has been asked lots of times before, but searches really did not turn up anything]
I am using nginx with SSI enabled to assemble pages and page-fragments from upstream servers.
upstream U1 produces the main page (the one containing SSI include directives) and wants nginx to cache its response (the page with the unresolved SSI include directives). Thus U1 sends the main page with Cache-Control: max-age=60.
The includes come from upstream U2 and are also cacheable from the POV of U2, hence U2 adds a max-age for those. The max-age could be less than 60 or more than 60.
What I want nginx to do is to cache the upstream response for the main page and also cache the upstream responses for the includes - which nginx does as the debug log suggests.
In addition I of course want nginx to strip/adjust the Cache-Control / max-age when the assembled page is sent to the client.
Unfortunately nginx seems to simply copy the max-age of the main page upstream response and send it to the client - which is obviously misleading information since the cacheabilty of the response is unknown or the lowest max-age of all includes.
Can anyone help me on how I get nginx to at least remove the misleading Cache-Control header?
ssi_last_modified is related and yields the correct default behavior: http://nginx.org/en/docs/http/ngx_http_ssi_module.html#ssi_last_modified
More information about the nginx