wandenberg / nginx-selective-cache-purge-module

126 stars 20 forks source link

Subrequest for purge never returns when called from lua #11

Open aguidrevitch opened 7 years ago

aguidrevitch commented 7 years ago

I'm using the following setup

   location ~ /purge(.*) {
        selective_cache_purge_query "$1";                                                 
    }        

   location ~ /mpurge {                                                                                                                                                            
        content_by_lua_block {                                                            
            local res = ngx.location.capture("/purge/*")
            ngx.print(res.status)
            ngx.print(res.body)
            return
        }
    }

It just hangs. I can only guess the module does not close the connection.

wandenberg commented 7 years ago

What happens if you call the /purge directly? And using a Lua client but outside Nginx? Just trying to figure out if the problem is on module or some combination of module, Lua and Nginx.

aguidrevitch commented 7 years ago

I get 400 status with empty body for ngx.location.capture("/purge"). If I call it from browser - it just works as expected. I was able to make it work using lua-resty-http from withing nginx. So basically it hangs when some content is returned by the module. It might have something to do with buffering as well

aguidrevitch commented 7 years ago

It might have something to do with buffering as well https://github.com/openresty/lua-nginx-module/issues/415