I am using Nginx to cache some responses. The backend that generates these responses, sets a common Cache-control
header for all the responses. However, I need to cache some of the responses for a longer duration than the others. That is I need to modify the cache-control
header before it is taken into consideration by the proxy_pass
directive.
I am using the ngx_lua_module
and want to modify the Cache-Control
header in the internal
location block using header_filter_by_lua_block
directive. The intended config looks like the following:
location / {
proxy_pass /actual;
proxy_cache something;
}
location = /actual {
internal;
proxy_pass https://backend;
proxy_cache off;
header_filter_by_lua_block {
-- modify cache-control header based on request/response parameters
}
}
However I couldn't figure out a way to achieve this internal redirection via proxy_pass
. I would appreciate any insight you have to make this work.