Skip to content

Instantly share code, notes, and snippets.

@douglasmiranda
Last active May 8, 2018 06:18
Show Gist options
  • Save douglasmiranda/01b9a5dedfc249ccabbc4c9878299863 to your computer and use it in GitHub Desktop.
Save douglasmiranda/01b9a5dedfc249ccabbc4c9878299863 to your computer and use it in GitHub Desktop.
Nginx Microcaching
# ...
# In Django you can tell the Nginx to not cache with:
# https://docs.djangoproject.com/en/2.0/topics/http/decorators/#module-django.views.decorators.cache
# Microcache - Want 150 requests/sec to become 1200?
#
# https://www.nginx.com/blog/benefits-of-microcaching-nginx/
# http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_cache
proxy_cache_path /tmp/cache keys_zone=cache:10m max_size=10g levels=1:2 inactive=600s max_size=100m;
server {
# ...
# Microcache
proxy_cache cache;
proxy_cache_lock on;
proxy_cache_valid 200 1s;
proxy_cache_use_stale updating;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment