Nginx更新静的ページは有効ではありません

3262 ワード

今日はNginxを逆エージェントにするvueをフロントエンドにするwebを更新しました.vueページの更新が完了したことを発見した後、nginxまたはnginxを再ロードし、静的ページも更新されなかった.
古いNginx構成
このように構成して静的ページを更新するのは問題があります.
#user  nobody;
worker_processes  1;

#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 {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
	    listen       80;
	    server_name  localhost;
	
	    #charset koi8-r;
	
	    #access_log  logs/host.access.log  main;
	    
	    location / {
		    root   D:/police/terminal-client; 
		    index  index.html index.htm;
		}
		
		location /api/ {
	    	proxy_pass      http://localhost:8888/;
            proxy_redirect  off;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
	}
}

解決策
  • Nginxはnginxを配置する.conf sendfileをoff(デフォルトはon)
  • に設定
  • Nginx
  • を再起動
  • 右クリックChromeブラウザ更新健「キャッシュをクリアしてハードに再ロード」(Chromeブラウザのこのステップでは重要で、通常のリフレッシュも有効ではありません.他のブラウザ、例えば火狐、通常のリフレッシュでいい)
  • 変更後のNginx構成
    次の商品を追加
    #user  nobody;
    worker_processes  1;
    
    #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 {
        include       mime.types;
        default_type  application/octet-stream;
    
        #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
        #                  '$status $body_bytes_sent "$http_referer" '
        #                  '"$http_user_agent" "$http_x_forwarded_for"';
    
        #access_log  logs/access.log  main;
    
        sendfile        off;
        #tcp_nopush     on;
    
        #keepalive_timeout  0;
        keepalive_timeout  65;
    
        #gzip  on;
    
        server {
    	    listen       80;
    	    server_name  localhost;
    	
    	    #charset koi8-r;
    	
    	    #access_log  logs/host.access.log  main;
    	    
    	    location / {
    		    root   D:/police/terminal-client; 
    		    index  index.html index.htm;
    		}
    		
    		location /api/ {
    	    	proxy_pass      http://localhost:8888/;
                proxy_redirect  off;
                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            }
    	}
    }
    

    Nginx sendfile構成
    sendfile:onがファイルの効率的な転送を開始するモードに設定します.sendfileは、Nginxがファイルを転送するときにディスクとtcp socketの間で直接データを転送することができる.このパラメータがオンでない場合は、まずユーザ空間(Nginxプロセス空間)でbufferを申請し、read関数でデータをディスクからcacheに読み出し、cacheからユーザ空間のbufferに読み出し、write関数でデータをユーザ空間のbufferからカーネルのbufferに書き込み、最後にtcp socketに書き込む.このパラメータをオンにすると、ユーザーbufferを経由せずにデータを通過させることができます.