proxy cache

Michał Jaszczyk jasiu85 at gmail.com
Tue May 19 17:39:59 MSD 2009


>> 1. proxy_cache_valid is set to 1h and upstream's response is valid for 2h.
>
> nginx will cache for 2h.
>
>> 2. proxy_cache_valid is set to 2h and upstream's response is valid for 1h.
>
> nginx will cache for 1h.
>
>> 3. proxy_cache_valid is set to 1h and upstream's response doesn't
>> contain any caching hints.
>
> nginx will cache for 1h.

This just means that upstream's caching instructions are more
important than proxy_cache_valid, right?


>> What happens if the client sends "If-Modified-Since" header?
>
> This header does not send to backend, however, nginx may responses 304.

I'm not sure if I understand. Let's imagine some scenarios (I-M-S
stands for If-Modified-Since, L-M stands for Last-Modified):

1. Client sends I-M-S, Nginx has response in cache, cached response
has L-M < I-M-S, Nginx sends 304.

2. Client sends I-M-S, Nginx has response in cache, cached response
has L-M > I-M-S, Nginx serves response from cache.

3. Client sends I-M-S, Nginx doesn't have response in cache, sends
request to upstream, upstream's L-M < I-M-S, Nginx stores response in
cache and sends 304.

4. Client sends I-M-S, Nginx doesn't have response in cache, sends
request to upstream, upstream's L-M > I-M-S, Nginx stores response in
cache and sends response from upstream.

Am I right?

Regards,

-- 
Michał Jaszczyk





More information about the nginx mailing list