server { listen 8000 default_server; server_name example.com; charset utf-8; root /var/www/example; location / { include uwsgi_params; uwsgi_pass unix:/var/www/awesome3-gamma/awesome3.sock; } # Set Cache for my Json api # I DO NOT WANT TO CACHE /api/search !!!! # I let expires 1M for json responses, and try with proxy_pass # as https://groups.google.com/forum/embed/#!topic/openresty-en/apyaHbqJetU location ~* \.(?:json)$ { expires 1M; access_log off; add_header Cache-Control "public"; } location /api { include uwsgi_params; uwsgi_pass unix:/var/www/awesome3-gamma/awesome3.sock; allow XX.XX.XXX.XXX:; deny all; } } # Set cache dir for nginx proxy_cache_path /tmp/nginx levels=1:2 keys_zone=my_zone:10m inactive=60m; proxy_cache_key "$scheme$request_method$host$request_uri"; # Attempt to delete single file cache - skip it # http://serverfault.com/questions/493411/how-to-delete-single-nginx-cache-file # curl -s -o /dev/null -H "X-Update: 1" mydomain.com # proxy_cache_bypass $http_x_update; # Here I set a proxy server: # I try to proxy_pass /api/search # with no cache settings # Virtualhost/server configuration server { listen 80 default_server; server_name example.com; root /var/www/example; charset utf-8; location /api/search { proxy_pass http://example:8000/api/search; } # can cache my API won't change location /api { add_header X-Proxy-Cache $upstream_cache_status; proxy_cache my_zone; proxy_cache_use_stale updating; proxy_cache_lock on; # proxy_cache_valid any 30s; proxy_cache_valid 30d; proxy_ignore_headers X-Accel-Expires Expires Cache-Control; proxy_pass http://example.com:8000/api; } } # like this, in my browser I still see all api request as # add_header Cache-Control "no-cache, must-revalidate, max-age=0";