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 ...
Get Nginx Essentials now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.