サイトの最新バージョンを表示する際の奇妙な Nginx の問題

サイトの最新バージョンを表示する際の奇妙な Nginx の問題

私たちは Nginx 1.6.2 を実行しており、バックエンド サーバーとともにロード バランサー (プロキシを使用) としてセットアップしています。先日、バックエンド サーバーを更新しても、その変更が Web フロントエンドに表示されないことに気付きました。古いバージョンが表示され続けます。

私たちがやったこと:

  1. テストしました全てブラウザでも同じ結果になります。
  2. Nginx 1.9.4 にアップグレードしましたが、問題は解決されません
  3. キャッシュの問題を排除するために、Cache-Control を no-cache に設定しました。開発者ツールで関連ファイルを確認すると、変更日が古い日付で表示され、実際に更新された日付が表示されていないことに気付きました。
  4. /var/lib/nginx/tmp/proxy/ にあるファイルをクリアしました

さらに、ここで取り上げている特定のファイルは.cssそして.jsファイル

最後に、Web バックエンドの 1 つに直接接続すると、完璧に動作します。これがNginxに関連していると考えられる理由です)。

これに関してアドバイスや推奨事項があれば、ぜひお知らせください。

js ファイルの応答ヘッダー:

Response headers:
Connection:keep-alive
Content-Length:33365
Content-Type:application/javascript
Date:Fri, 25 Sep 2015 13:07:58 GMT
Last-Modified:Sat, 08 Aug 2015 17:56:52 GMT
Server:nginx/1.9.4
Strict-Transport-Security:max-age=31536000

Request headers
Accept:*/*
Accept-Encoding:gzip, deflate, sdch
Accept-Language:en-US,en;q=0.8
Cache-Control:no-cache
Connection:keep-alive
Cookie:__utmt=1; JSESSIONID=18CB152C40CC7C3A9C8C2058BC9ABA1C;      __utma=129083286.1723352187.1441183278.1443165488.1443186453.22; __utmb=129083286.2.10.1443186453; __utmc=129083286; __utmz=129083286.1442402128.17.2.utmcsr=console.aws.amazon.com|utmccn=(referral)|utmcmd=referral|utmcct=/support/chat
Host:ourdomain.com
Pragma:no-cache
Referer:https://ourdomain.com/dashboard/adminDashboard
User-Agent:Mozilla/5.0 (Linux; Android 4.4.2; Nexus 4 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.122 Mobile Safari/537.36

.css ファイルのレスポンス ヘッダー

Connection:keep-alive
Content-Length:31125
Content-Type:text/css
Date:Fri, 25 Sep 2015 13:07:57 GMT
Last-Modified:Thu, 27 Aug 2015 08:44:24 GMT
Server:nginx/1.9.4
Strict-Transport-Security:max-age=31536000

Nginx の設定

user nginx;
worker_processes 22;
pid /var/run/nginx.pid;

events {
        worker_connections 768;
        # multi_accept on;
}

http {

        ##
    # Basic Settings
        ##

    sendfile off;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;
        client_max_body_size 15M;
        # server_tokens off;

 proxy_headers_hash_max_size 51200;
        proxy_headers_hash_bucket_size 6400;
#         server_names_hash_bucket_size 6400;
        # server_name_in_redirect off;

#        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        ##
    # Logging Settings
        ##

    access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;

        ##
    # Gzip Settings
        ##

    gzip on;
        gzip_disable "msie6";
        # gzip_vary on;
        # gzip_proxied any;
        # gzip_comp_level 6;
        # gzip_buffers 16 8k;
        # gzip_http_version 1.1;
        # gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

        ##
    # nginx-naxsi config
        ##
    # Uncomment it if you installed nginx-naxsi
        ##
        #include /etc/nginx/naxsi_core.rules;

        ##
    # nginx-passenger config
        ##
    # Uncomment it if you installed nginx-passenger
        ##

    #passenger_root /usr;
        #passenger_ruby /usr/bin/ruby;

        ##
    # Virtual Host Configs
        ##

    include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
       # include /etc/nginx/sites-available/*;

#upstream backend {
#    server 128.199.57.230;
#    server 104.236.50.191;
#    server 10.0.0.3:80;
#}
#server {
#        listen 80;
#location / {
#            proxy_pass http://backend;
#        }

関連情報