Maybe nginx lua could be extended to re-use file stat and open
functions from Nginx?
There's the nginx file cache interface too that maybe could be
leveraged from Lua?
As far as I know there's no straightforward way to stat from Lua to
check file time stamp ?
Maybe one could use FFI to use the syscalls directly.
Did you already create something to solve these problems, Aapo?
Regards,
Tor
2014-10-03 21:14 GMT+02:00 Yichun Zhang (agentzh) <age...@gmail.com>:
> Hello!
>
> On Thu, Oct 2, 2014 at 7:23 AM, Aapo Talvensaari wrote:
>> How do you like this design? Obviously I will add caching to this as well
>> (which can be disable for development). How should I cache these?
>>
>
> It depends on the actual caching requirements. Like: do we need to
> re-compile when the .scss file changes?
>
>> 1. Write a compiled .css file to same dir where the .scss file was
>> 2. Use shm (ngx.shared.DICT)
>> 3. Use lua-resty-lrucache
>> 4. Store compiled to datastore like memcached, redis etc.
>> 5. Support all of these and ability to set configuration parameters via
>> nginx.conf
>>
>
> Personally I like 1) most. But we might need a way to invalidate the
> .css file when the .scss file changes (maybe a timer or something to
> save the stat() system call upon every request).
>
>> Also, is the content_by_lua a way to go with this compilation phase?
>
> Looking fine to me.
>
>> There
>> is also a body_filter_by_lua and other phases where this might be attached.
>
> The whole point of body_filter_by_lua is that you cannot control the
> content handler, like proxy_pass. You can still do streaming
> processing, for example, easily in your content_by_lua.
>
>> I'm using ngx.location.capture here to retrieve the .scss content, but
>> should I use something else?
>>
>
> ngx.location.capture should be avoided here because I don't see why we
> should pay the price of subrequests in this context. We can manipulate
> the files directly from within Lua. The only thing we need to be
> serious about is how to reduce the number of (file) system calls (for
> the best performance).
>
> Regards,
> -agentzh.