2016-10-03 28 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

您的配置有多個問題。您已經定義了一個location ~* \.html$塊,沒有定義root。您還不必要地嵌套位置塊。

嘗試這樣:

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

location/{ 
} 

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

rootindex指令是在server塊級別定義爲所有位置塊繼承。

有關更多詳細信息,請參見the root directivethe location directive。另外,這個概述how nginx processes a request