O'Reilly logo

Nginx Essentials by Valery Kholodkov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Caching

Once Nginx is set up as a reverse proxy, it's logical to turn it into a caching proxy. Fortunately, this can be achieved very easily with Nginx.

Configuring caches

Before you can enable caching for a certain location, you need to configure a cache. A cache is a filesystem directory containing files with cached items and a shared memory segment where information about cached items is stored.

A cache can be declared using the proxy_cache_path directive:

proxy_cache_path <path> keys_zone=<name>:<size> [other parameters...];

The preceding command declares a cache rooted at the path <path> with a shared memory segment named <name> of the size <size>.

This directive has to be specified in the http section of the configuration. Each instance of the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required