是否可以在nginx中設置內容類型相關的過期標題?我對nginx很陌生,並嘗試以下方法:內容類型相關的nginx過期標題
location ~ /files\.php$ {
...
if ($content_type = "text/css") {
add_header X-TEST1 123;
expires 7d;
}
if ($content_type = "image/png") {
add_header X-TEST2 123;
expires 30d;
}
if ($content_type = "application/javascript") {
add_header X-TEST3 123;
expires 1d;
}
#testing
if ($content_type != "text/css") {
add_header X-TEST4 abc;
}
#testing
if ($content_type = text/css) {
add_header X-TEST5 123;
}
}
但是,所有請求中添加的唯一頭是「X-TEST4」。 我知道其他使用解決方案文件擴展名:
location ~* \.(ico|css|js|gif|jp?g|png)\?[0-9]+$
但它並不適用於我的應用程序。
沒有,這不物。請參閱http://wiki.nginx.org/HttpCoreModule#location – dompie