# Ngx\_lua v0.1.4: ability to disable the Lua code cache

**URL:** <https://www.ruby-forum.com/t/ngx-lua-v0-1-4-ability-to-disable-the-lua-code-cache/202193>\
**Category:** NGINX\
**Created:** [January 24, 2011, 11:33am UTC](https://www.ruby-forum.com/t/ngx-lua-v0-1-4-ability-to-disable-the-lua-code-cache/202193 "2011-01-24T11:33:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [January 24, 2011, 11:33am UTC](https://www.ruby-forum.com/t/ngx-lua-v0-1-4-ability-to-disable-the-lua-code-cache/202193/1 "2011-01-24T11:33:10Z")

</div>

Hi, folks!

I’m delighted to announce the ngx\_lua v0.1.4 release which features  
the ability to disable the Lua code cache to ease Lua development. You  
can get the release tarball from the download page:

[https://github.com/chaoslawful/lua-nginx-module/downloads](https://github.com/chaoslawful/lua-nginx-module/downloads)

By default, Lua code loaded into the ngx\_lua module will be cached  
(the compiled/JIT’d form will be cached). So changing .lua files  
requires reloading or restarting the nginx server. From this release,  
we can use the following directive to disable the code cache:

lua\_code\_cache off;

Then the Lua files referenced in set\_by\_lua\_file, content\_by\_lua\_file,  
access\_by\_lua\_file, and rewrite\_by\_lua\_file won’t be cached at all,  
and Lua’s “package.loaded” table will be cleared at every request’s  
entry point (such that Lua modules won’t be cached either). So  
developers and enjoy the PHP-way, i.e., edit-and-refresh.

But please note that Lua code inlined into nginx.conf like those  
specified by set\_by\_lua, content\_by\_lua, access\_by\_lua, and  
rewrite\_by\_lua will _always_ be cached because only nginx knows how to  
parse nginx.conf and the only way to tell it to re-load the config  
file is to send a HUP signal to it or just to restart it from scratch.

For now, ngx\_lua does not support the “stat” mode like Apache’s  
mod\_lua, but we will work on it in the future.

This release also contains a small over-all optimization that the keys  
used for Lua code cache lookups are pre-calculated at config time  
wherever possible.

The ngx\_lua module embeds the Lua/LuaJIT interpreter into the nginx  
core and integrates the powerful Lua threads (aka Lua coroutines) into  
the nginx event model by means of nginx subrequests.

You can get the latest source code and full documentation from the  
ngx\_lua’s project page:

[GitHub - openresty/lua-nginx-module: Embed the Power of Lua into NGINX HTTP servers](https://github.com/chaoslawful/lua-nginx-module/)

Have fun!  
-agentzh

---

<div class="post-metadata">

**Author:** ![agentzh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4da419/32.png) [@agentzh](https://www.ruby-forum.com/u/agentzh)\
**Post date:** [February 3, 2011, 8:24pm UTC](https://www.ruby-forum.com/t/ngx-lua-v0-1-4-ability-to-disable-the-lua-code-cache/202193/2 "2011-02-03T20:24:09Z")

</div>

Hi,

I’m using this module on one of my production servers and seems like  
memory leak presents in this module.  
My lua config is below.  
location / {  
include proxy.conf;

```
   location = /check-spam {
         internal;

         include spam_fastcgi.conf;
       }

       lua_need_request_body on;

       rewrite_by_lua '
         if ngx.var.request_method ~= "POST" then
           return
         end
         local res = ngx.location.capture(
         "/check-spam",
         { method = ngx.HTTP_POST, body = ngx.var.request_body }
         )
         a=string.sub(res.body,0,4)=="SPAM"
         if a then
           return ngx.redirect("/terms-of-use.html")
         end
       ';

     }
```
