I'm using Nginx as a caching proxy server. I have problems with caching responses using both X-Accel-Expires and Cache-Control headers.
My upstream returns some request body with headers to nginx:
[...]
X-Accel-Expires: 60
Cache-Control: no-cache
[...]
My intent is that nginx will cache response for 60 seconds but clients will get only cache-control: no-cache header (so they will not cache response in the browser).
But nginx isnt caching that response. Nginx honour cache-control header and ignoring X-Accel-Expires header. I thought that X-Accel-Expires is "stronger" that Cache-Control but it is not.
Is there any way to change that?
I know that I can use:
proxy_ignore_headers Cache-Control;
But I cant do that because I don't have X-Accel-Expires headers in every response from upstream server.
To sum up when I return thoose headers from upstream:
X-Accel-Expires: 60
Cache-Control: no-cache
I want to cache response in nginx cache for 60s but return to clients cache-control: no-cache
But when I return this:
Cache-Control: max-age=90
(without X-Accel-Expires header) I want to cache response in nginx cache for 60s and return to clients Cache-Control: max-age=90 header.
Is this possible?
My upstream returns some request body with headers to nginx:
[...]
X-Accel-Expires: 60
Cache-Control: no-cache
[...]
My intent is that nginx will cache response for 60 seconds but clients will get only cache-control: no-cache header (so they will not cache response in the browser).
But nginx isnt caching that response. Nginx honour cache-control header and ignoring X-Accel-Expires header. I thought that X-Accel-Expires is "stronger" that Cache-Control but it is not.
Is there any way to change that?
I know that I can use:
proxy_ignore_headers Cache-Control;
But I cant do that because I don't have X-Accel-Expires headers in every response from upstream server.
To sum up when I return thoose headers from upstream:
X-Accel-Expires: 60
Cache-Control: no-cache
I want to cache response in nginx cache for 60s but return to clients cache-control: no-cache
But when I return this:
Cache-Control: max-age=90
(without X-Accel-Expires header) I want to cache response in nginx cache for 60s and return to clients Cache-Control: max-age=90 header.
Is this possible?