FRiCKLE/ngx_cache_purge

fastcgi_cache_purge does not work when a reverse proxy is in use

caffeinejolt opened this issue · 2 comments

Hello,

Noticed something odd with your module with nginx 1.8. The module is not able to purge fastcgi cache items when the item cached resulted from a request proxied via a downstream nginx instance. In other words...

This works fine:

client sends GET request -> nginx -> stored fastcgi cache
local client sends PURGE -> nginx -> nginx_ngx_cache_purge -> removes cache item

This does not work:

client sends GET request -> nginx acting as reverse proxy -> nginx -> stored fastcgi cache
local client sends PURGE -> nginx -> nginx_ngx_cache_purge -> fails to remove cache item (issuing a 404 as if it were not there)

I have verified that the cache key is the same for each (4879149fc65502f028b5fccefe741490) when determining the above. Also, the cache item did not expire before attempting to run the PURGE.

Interestingly... if I do this:

client sends GET request -> nginx acting as reverse proxy -> nginx -> stored fastcgi cache
client sends GET request -> nginx -> served cached item created in the above step
local client sends PURGE -> nginx -> nginx_ngx_cache_purge -> removes cache item

It works - its as if the request that is not sent through the reverse proxy, even though it just got a cached result, updated something in nginx which allowed nginx_ngx_cache_purge to realize there was a cached item to remove.

Furthermore, I ran some tests in which only this request methodology was used in which the cached item was refreshed several times (expired and updated):

client sends GET request -> nginx acting as reverse proxy -> nginx -> stored fastcgi cache

And nginx_ngx_cache_purge is never able to purge it. Bottom line is that nginx_ngx_cache_purge->fastcgi_cache_purge never works if a nginx 1.8 reverse proxy is in use which hands off requests to nginx 1.8 running a fastcgi cache.

Hopefully the above information will yield clues as to where the problem may be.

Regards,
Michael

I'm having the same problem. Nginx as reverse-proxy (1.7.10), and Nginx as webserver (1.8.0).
Any solutions about this? I'm able to do any testing required!!

regards

Francisco.

I was running into an similar issue my setup was Nginx running as proxy server (1.8.0) -> Nginx running as app server (1.8.0) -> php-fpm and I had gzip turned on in both instances.

So the proxy server were duplicating the cache for both clients which accepts and not gzip. Disabling gzip on nginx app solved my problem.