Nginx high performance proxy caching system

Nginx has been built with ncache in the core. It’s very fast and offers great performance. It works quite nicely – you install nginx as a front-end proxy server and forward all php queries to Apache back-end. Then you set-up nginx to cache response from Apache back-end to static files on a file system (or even RAM disk).

in http{} section please define the path to proxy cache, levels, keys_zone name, expire time in minutes and max size in megabytes:

proxy_cache_path /path/to/cache levels=1:2 keys_zone=staticfilecache:180m max_size=500m;
proxy_temp_path /path/to/proxy_temp;

Please note that proxy_cache_path and proxy_temp_path should be on the same file system.

proxy_cache_key “$scheme://$host$request_uri $do_not_cache”;
proxy_cache staticfilecache;

in server {} location setting you should define the following values/settings:

proxy_cache_valid 200 15m;

The above caching settings will cache all valid 200 response for 15 minutes.

Leave a Reply