Is cache being used?

Ben Lancaster benlancaster at
Tue Jul 26 16:26:37 UTC 2011

On 26 Jul 2011, at 16:54, egrueda wrote:

> Hi all. I have a newbie question:
> How can I make sure content is delivered from nginx's cache and not from
> backend server or web-browser cache?
> How do I check it?
> Thanks!

The $upstream_cache_status variable is your friend here. Add the following to your server config:

add_header X-Cache-Status $upstream_cache_status;

You'll see http headers like:

X-Cache-Status: MISS

in your responses. MISS if it wasn't served from Cache (and never will be), HIT if it was or EXPIRED if it the cache was updated with your request.

You can forcibly tell any intermediate caches not to cache your responses with stuff like:

expires -1;
add_header Cache-Control private;

Hope that helps.

More information about the nginx mailing list