Nginx – How to Confirm working of Nginx Caching Proxy

apache-2.2cachenginxreverse-proxyweb-server

I am having nginx on port 80 and apache on port 8080 on same server.

I have configured nginx such that it act as reverse proxy(i am not sure whether its working or not) using this tutorial http://tumblr.intranation.com/post/766288369/using-nginx-reverse-proxy.

steps i followed to verify proxy.

  • opened same page on two different machines within an interval of 5
    seconds.

but in the apache access.log every request is showing 200 response code.Does that indicate that caching is not working?

and nginx access.log is showing nothing.

Best Answer

The tutorial that you are referring has nothing to do with nginx cache. So, it's definetly that nginx caching is not working if your config is similar to that from tutorial.

But in general, nginx has special variable:

$upstream_cache_status — keeps status of accessing a response cache (0.8.3). The status can be one of “MISS”, “BYPASS”, “EXPIRED”, “STALE”, “UPDATING” or “HIT”.

http://nginx.org/en/docs/http/ngx_http_upstream_module.html#variables

You can do with this variable whatever you want (e.g. log it into access log, or return it with the response headers).