Hello!
I have a fine working NGINX setup to cache a web service with proxy_cache_methods set to POST.
The proxy_cache_key is set to "$request_uri|$request_body", because the responses are identical for equal requests about the same day.
So the cache is flushed every midnight.
The problem is, that I only want to cache "valid" responses. It's necessary to check the web service response before caching.
Rarely the web service responses are not valid because of special messages inside the response.
It is sufficient to detect these responses with simple regular expressions.
And these responses shouldn't be cached. If the client repeats the request, the response of the web service mostly is valid again within seconds.
But with my actual setup the not valid responses are served by the cache for the whole day.
Is it possible to solve this use case with Lua and what's the best practice?
I tried with body_filter_by_lua to detect not valid responses. That works fine, but the not valid response is already cached before the filter.
Thanks in advance,
Falk Berger