How to choose a correct value for open_file_cache in nginx configuration?

The open file cache is a caching system for metadata operations (file mtime, file existence etc), not for file content, so it helps but not as much as you would expect.

Some workarounds you could try are:

  • Lower the gzip compression ration if you have turned dynamic gzip on.
  • If you are running a sufficiently recent kernel (> 2.6.22) try turning aio on. Check http://wiki.nginx.org/HttpCoreModule#aio
  • Disable access logging. This alone can give you a very high performance jump. Make sure you don't need it though!
  • Try an actual file content caching module such as https://github.com/bpaquet/ngx_http_enhanced_memcached_module. Warning: this will require recompiling nginx from source!