lua_code_cache 说明
nginx+lua开发时因为已经加载进内存,修改lua脚本不会起作用,这样不方便调试。nginx配置中将lua_code_cache配置成on/off来控制是否关闭lua 的cache缓存,如果设置为off.则每次修改lua脚本都会重新加载新的lua代码,从而实现快速调试响应。同时状态为off时启动或重启nginx都会提示:nginx: [alert] lua_code_cache is off; this will hurt performance in /path/to/nginx.conf。因为这会影响nginx性能表现。
注意!!!!!! 开发调试的时候使用off, 线上运行时设置为on。
配置方式
在nginx.conf那里配置
lua_code_cache off;#调试模式(即关闭lua脚本缓存)
events {worker_connections 1024;}http {include mime.types;default_type application/octet-stream;sendfile on;keepalive_timeout 65;server {listen 8081;location / {lua_code_cache off;#调试模式(即关闭lua脚本缓存)content_by_lua_file '/lua/hello.lua';}}
配置完了需要刷新配置文件
[root@zjj101 lua]# openresty -s reload
