"Hid" a slow REST API for nginx.
Known difficulties arose - how to ensure cache coherence?
If for a pair of url it could still be done purely through the configuration, then for ten or more it was already beyond common sense.
All I saw was a bit monstrous.
I really wanted this (or similar) configuration:
location ~ ^/zone_two/(.*)$ { proxy_cache zone_two; proxy_cache_key $document_uri; proxy_cache_valid 60m; set $do_invalidate 0; if ($request_method = PUT) { set $do_invalidate 1; } proxy_cache_invalidate $do_invalidate;
')
As a result, a bicycle was born -
github.com/egorse/ngx-proxy-cache-invalidate .
Works with 1.8.0, 1.8.1.
Other versions of nginx did not test.
Criticism
is welcome. Especially if the "giblets" nginx.
Update1: it is not a single element in the cache zone that is disabled, but _all_ elements from the cache zone defined by proxy_cache.