-- nginx.conf
worker_processes 2;
user root;
pcre_jit on;
events {
worker_connections 1024;
}
http {
lua_package_path '$prefix/?.lua;$prefix/resty_modules/lualib/?.lua;;';
lua_code_cache off;
default_type text/plain;
keepalive_timeout 65;
server {
listen 8080;
location / {
content_by_lua_file lua/not_found.lua;
}
location = /test {
# rewrite_by_lua_file lua/check.lua;
content_by_lua_file lua/test.lua;
}
location = /other {
content_by_lua_file lua/other.lua;
}
}
}
-- test.lua
local res = ngx.location.capture("/other")
ngx.say(res.body)
local m, err = ngx.re.match("hello, mei", "HELLO, (.{2})", "i")
ngx.say(m[0])
ngx.say(m[1])
-- other.lua
local res = ngx.location.capture("/other")
ngx.say(res.body)
local m, err = ngx.re.match("hello, mei", "HELLO, (.{2})", "i")
ngx.say(m[0])
ngx.say(m[1])
===================================
如果lua_code_cache on; 则没有任何问题
当lua_code_cache off;
curl http://localhost:8080/other
curl http://localhost:8080/test 后会出现子请求循环
这是什么原因呢?