nginx-selective-cache-purge-module icon indicating copy to clipboard operation
nginx-selective-cache-purge-module copied to clipboard

Subrequest for purge never returns when called from lua

Open aguidrevitch opened this issue 7 years ago • 3 comments

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.

aguidrevitch avatar Jul 06 '17 16:07 aguidrevitch

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.

wandenberg avatar Jul 06 '17 17:07 wandenberg

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 avatar Jul 06 '17 17:07 aguidrevitch

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

aguidrevitch avatar Jul 06 '17 17:07 aguidrevitch