2016-10-03 8 views
0

最も基本的なnginx.confの例をとり、htmlファイルにno-cacheコントロールを追加しようとしました。私が見つけたものすべてを試しましたが、何も動作していないようです。これは私の現在の設定ファイルですnginxの設定に関係なくキャッシュされたHtmlファイル

user nobody; 
worker_processes 3; 

pid logs/nginx.pid; 

events { 
    worker_connections 1024; 
} 

http { 
    include  mime.types; 
    default_type application/octet-stream; 

    server { 
     listen  80; 
     listen  [::]:80; 

     location/{ 
      location ~\/.+ { 
       root /var/www; 
       index index.html index.htm; 
      } 

      location ~* \.html$ { 
       expires -1; 
      } 
     } 
    } 
} 

私は間違っていますか?それはnginxのためか他の何かのためですか?

答えて

0

設定には複数の問題があります。 rootが定義されていないlocation ~* \.html$ブロックを定義しました。また、ロケーションブロックを不必要にネストすることもあります。

root /var/www; 
index index.html index.htm; 

location/{ 
} 

location ~* \.html$ { 
    expires -1; 
} 

rootindexディレクティブは、すべての場所のブロックによって継承されるserverブロック・レベルで定義されています。

はこのような何かを試してみてください。

詳細については、the root directiveおよびthe location directiveを参照してください。また、この概要はhow nginx processes a requestです。

関連する問題