Saya memiliki REST API di belakang proxy nginx. Proksi berfungsi dengan baik, namun saya tidak dapat menyimpan tanggapan apa pun. Bantuan apa pun akan sangat dihargai:
Konfigurasi nginx:
worker_processes 10;
error_log logs/error.log;
error_log logs/error.log notice;
error_log logs/error.log info;
pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
proxy_cache_path /path/to/cache/dir keys_zone=one:60m;
proxy_cache_methods GET HEAD POST;
upstream backend {
server server1 backup;
server server2 weight=5;
}
access_log logs/access.log;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 7076;
server_name localhost;
#charset koi8-r;
access_log logs/host.access.log;
location / {
add_header 'Access-Control-Allow-Origin' *;
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Headers' 'Content-Type,Accept';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
proxy_cache one;
proxy_cache_key $host$uri$is_args$args;
add_header X-Proxy-Cache $upstream_cache_status;
proxy_ignore_headers X-Accel-Expires Expires Cache-Control Set-Cookie;
proxy_ignore_headers Set-Cookie;
proxy_ignore_headers Cache-Control;
proxy_hide_header Cache-Control;
proxy_hide_header Set-Cookie;
proxy_pass http://backend;
}
}
}
Tidak peduli apa yang saya coba, Proxy-Cache selalu kembali sebagai MISS:
Header Permintaan adalah:
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Cache-Control:max-age=0
Connection:keep-alive
Host:nginxserver:portnumber
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 Safari/537.36
Header Respons adalah:
Access-Control-Allow-Credentials:true
Access-Control-Allow-Headers:Content-Type,Accept
Access-Control-Allow-Methods:GET, POST, OPTIONS
Access-Control-Allow-Origin:*
Connection:keep-alive
Content-Type:text/plain;charset=UTF-8
Date:Wed, 15 Oct 2014 16:30:18 GMT
Server:nginx/1.7.4
Transfer-Encoding:chunked
X-Proxy-Cache:MISS
Kecurigaan saya adalah ada sesuatu dengan header klien, tetapi bahkan jika saya mengeluarkan panggilan melalui curl dan memeriksa header, tidak ada respons.
Terima kasih sebelumnya
Cache-Control:max-age=0
... yang menyiratkan "jangan cache permintaan ini."