Is it possible to set a content-type dependent expires header in nginx? I'm quite new to nginx and tried the following:
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;
}
}
But the only header added is "X-TEST4" on all requests. I know about the other solution using file extension:
location ~* \.(ico|css|js|gif|jp?g|png)\?[0-9]+$
But it's not applicable for my application.