Writing a cache module

Igor Sysoev is at rambler-co.ru
Mon Sep 28 23:35:51 MSD 2009

On Mon, Sep 28, 2009 at 03:06:25PM -0400, Akins, Brian wrote:

> I need to write cache module that's not upstream based.  (Long story...)
> Reading through the upstream code and the proxy and fastcgi modules, it
> looks fairly simple.
> Just so I know I'm on the right track:
> - to get something from cache I should generate a key for r->cache, try to
> open file using ngx_http_file_cache_open, then "serve" it using
> ngx_http_cache_send (or replicate what it does).
> -to store something in cache, create a ngx_temp_file_t store my data in
> there, generate a key, then call ngx_http_file_cache_update to add that file
> to cache.
> Is that reasonable?


> Any gotchas?

Do not forget ngx_http_file_cache_free() for noncacheable responses.

Igor Sysoev

More information about the nginx mailing list