nginxでコンテンツタイプに依存するExpiresヘッダーを設定することは可能ですか? 私は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]+$
しかし、それは私のアプリケーションには当てはまりません。