August 2017
Intermediate to advanced
278 pages
8h 53m
English
To take advantage of microcaching, we expand on our previous recipe to reduce the timeout of the cache.
server {
listen 80;
server_name micro.nginxcookbook.com;
access_log /var/log/nginx/micro-access.log combined;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_cache micro;
proxy_cache_valid 200 10s;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
}
}
When you first look at it, 1 second timeouts seem like they won't provide any help. For a busy site, the reduction of requests which have to hit the backend server can be significantly dropped. It also means that your burst ability is greatly increased, allowing your site to handle a spike in traffic without ...
Read now
Unlock full access