Postingan

Menampilkan postingan dari Agustus, 2021

Nginx Cache

Gambar
 Today I learn nginx feature to cache the web response. Reference :  http://nginx.org/en/docs/http/ngx_http_proxy_module.html several cache config that I think useful are cache size, cache ttl, cache condition & key, cache background update, cache lock / singleflight, and header cache status information. combined it may looks like this  proxy_cache_path /var/cache/adibiarso levels=1:2 keys_zone=adibiarso_cache:10m max_size=200m inactive=10m use_temp_path=off; location / { proxy_cache adibiarso_cache; proxy_cache_key "$request_uri"; proxy_cache_valid 200 404 1m; proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504; proxy_cache_background_update on; proxy_cache_lock on;      add_header X-Cache-Status $upstream_cache_status; proxy_pass http://127.0.0.1:5000; } Breakdown proxy_cache_path option to set file cache location, directory level, max size, and inactive state http://nginx.org/en/docs/http/ngx_http_proxy_module.html#pr