Admin Books

DOWNLOAD Free e-Books for Linux Admin Servers :

nginx to cache the results from apache


The way to get better performance is to get nginx to cache the results from apache, by adding the following to your nginx virtual host definition :

                proxy_cache one;
                proxy_cache_use_stale error timeout invalid_header updating;
                proxy_cache_key $scheme$host$request_uri;
                proxy_cache_valid       200 301 302 20m;
                proxy_cache_valid       404 1m;
                proxy_cache_valid       any 15m;



where the proxy_cache named one is defined in nginx.conf as such :

proxy_cache_path /usr/local/nginx/proxy levels=1:2 keys_zone=one:15m inactive=7d max_size=1000m;


The proxy_cache_valid entries above define different cache times for various response codes