nginx-0.7.44

Jérôme Loyet jerome at loyet.net
Tue Mar 24 21:22:03 MSK 2009


2009/3/24 Igor Sysoev <is at rambler-co.ru>:
> On Tue, Mar 24, 2009 at 05:30:02PM +0100, J?r?me Loyet wrote:
>
>> 2009/3/24 Igor Sysoev <is at rambler-co.ru>:
>> > On Tue, Mar 24, 2009 at 05:07:23PM +0100, J?r?me Loyet wrote:
>> >
>> >> 2009/3/23 Igor Sysoev <is at rambler-co.ru>:
>> >> > On Mon, Mar 23, 2009 at 10:42:45PM +0800, Delta Yeh wrote:
>> >> >
>> >> >> How to use the cache feature?
>> >> >> What kind of cache does it support?
>> >> >
>> >> > Here is configuraiton example:
>> >> >
>> >> > http {
>> >> >     proxy_cache_path   /path/to/cache  levels=1:2
>> >> >                        keys_zone=NAME:10m
>> >> >                        inactive=5m     clean_time=2h00m;
>> >> >
>> >> >     server {
>> >> >         location / {
>> >> >             proxy_pass    http://127.0.0.1;
>> >> >
>> >> >             proxy_cache   NAME;
>> >> >
>> >> >             proxy_cache_valid   200 302  1h;
>> >> >             proxy_cache_valid   301      1d;
>> >> >             proxy_cache_valid   any      1m;
>> >> >
>> >> >             proxy_cache_min_uses  1;
>> >> >
>> >> >             proxy_cache_use_stale   error  timeout invalid_header http_500;
>> >> >         }
>> >> >     }
>> >> >
>> >> > The cache currently ignores backend's Cache-Control, Expires, etc.
>> >>
>> >> hi Igor,
>> >>
>> >> Do I understand correctly the proxy_cache_use_stale directive:
>> >>
>> >> proxy_cache_use_stale   error  timeout invalid_header http_500;
>> >>
>> >> If cache is still valid {
>> >>   serve content from cache
>> >> } else {
>> >>   Ask fresh data to the backend
>> >>   if connection status IS IN  (proxy_cache_use_stale parameters) {
>> >>       serve content from cache
>> >>   } else {
>> >>       act as normal
>> >>   }
>> >> }
>> >
>> > Yes.
>>
>> Other question, how can I determine the maximum number of cache entrie
>> I have with a particular conf ?
>>
>> proxy_cache_path  /data/nginx/cache  keys_zone=one:10m;
>>
>> What is the size of keys on shared mem (X bytes). So that I can
>> extrapole the maximum number N of cache entries with YMo of shared
>> memory (N = (Y x 1024 x 1024) / X). (if there is nothing elese in the
>> shared mem and if the key size is constant)
>
> The key size is 128 bytes.

Thanks for the answer.

Is there a way to know the effective used size in the SHM segement ?

Another question about proxy_cache_valid. Let say I set it to 10m. I
do some hits and the requests are cached well. Now I update my conf
and set proxy_cache_valid to 30s and send a HUP signal to nginx. How
is already cached files timeout handled at restart or reload ?

Is the cache going to be mark as stale 30s after ?
Is the cache going to stay in the cache until its 10m timeout is
reached (and then be recached with a 30s timeout) ?

Thanks you very much. This cache module for proxy is just what we were
waiting for :)

++ Jerome





More information about the nginx mailing list