1、SPA模式配置
location /web{
alias /home/web/dist;
index index.html index.htm;
try_files uri/ @router;
etag off;
add_header Last-Modified "";
add_header Cache-Control no-store;
}
location @router {
rewrite ^.*$ /web/index.html last;
}
add_header Cache-Control no-store; 更改response header里的 Cache-Control 為 no-store;
proxy_buffering 參數(shù)默認(rèn)是on,改成offer解決數(shù)據(jù)被截?cái)嗟那闆r。
2、proxy_buffer 設(shè)置
proxy_buffering 默認(rèn)是on,如果proxy_buffers打開了,nginx會(huì)盡可能的讀取后端數(shù)據(jù)到buffer中,直至proxy_buffers設(shè)置的所有buffer都被寫滿或數(shù)據(jù)都被讀取完,此時(shí)nginx開始向客戶端傳輸數(shù)據(jù)。
相關(guān)配置:
proxy_buffering 默認(rèn)是on,buffer開關(guān)。
proxy_buffer_size nginx可從服務(wù)器一次接收的最大數(shù)據(jù)大小由 proxy_buffer_size 控制
proxy_buffers 用來設(shè)置讀取被代理服務(wù)器的緩沖區(qū)數(shù)目和大小
遇到的問題:proxy_buffering 沒有設(shè)置,取得默認(rèn)值on,出現(xiàn)異步接口值過大,數(shù)據(jù)返回為undefined。