So, I have following settings, related to caching:
------------------------------------------------
fastcgi_cache_bypass $skip_cache;
fastcgi_no_cache $skip_cache;
------------------------------------------------
And set of rules which are skipping cache, like
------------------------------------------------
if ($request_uri ~* "(\.well-known|acme-challenge)") {
set $skip_cache 1;
set $skip_cache_reason " - Rule2";
}
------------------------------------------------
The problem is that PHP sometimes returns wrong 301 redirect create, with wrong location, which looks like:
------------------------------------------------
HTTP/2 301
server: nginx
date: Wed, 17 Jan 2024 11:46:41 GMT
content-type: text/html; charset=UTF-8
location: https:///
x-cache-status: HIT
....
------------------------------------------------
While we're trying to find and fix the root cause I'd like to skip caching for such type of answers.
AFAIK 'if' works only before sending to upstream, so I can't just use something like 'if ($upstream_http_location = "https:///")'
I was going to create LUA script for checking that, but not sure into which phase I can add it, like which directive to use 'access_by_lua_file' or maybe 'log_by_lua_file', etc.
I also suspect there could not exist 'correct' LUA derictive for that as such procession could happen even before generating response.
So, is there any way to not cache based on upstream response?