nginx-modules / ngx_cache_purge

nginx module which support to purge ngx_http_(fastcgi|proxy|scgi|uwsgi)_module cache backend
Other
209 stars 34 forks source link

Failed to purge a cached POST method by key #40

Open yuriylygin opened 2 years ago

yuriylygin commented 2 years ago

That is what I have to initiate cache:

uwsgi_cache vsp-cache;
uwsgi_cache_lock on;
uwsgi_cache_lock_timeout 5s;
uwsgi_cache_valid 15m;
uwsgi_cache_key "$role:$proxy_host$uri$is_args$args:$request_body_md5";
uwsgi_cache_methods GET HEAD POST;

As it is shown I cache not only GET and HEAD methods but POST methods as well.

Purging is realized in a separate location with a key being passed within the url path:

location ~ ^/purge/develop/(.*) { #text
    allow              127.0.0.1;
    uwsgi_cache_purge  vsp-cache $1;
}

When I try to purge a cached GET request with the key associated with that request everything works just fine and the cached request is removed. But the same logic doesn't work when I try to purge a cached POST request. I get a response with 412 status code which means the key is not found I suppose.

The question is how to purge a cached POST request from NGINX cache with a key passed in the url path?