我尝试设置 max-age 标头指令和 Content-Disposition “附件”如下:
location / {
# set up max-age header directive for certain file types for proper caching
location ~* \.(?:css|js|ico|gif|jpe?g|png|mp3|mpeg|wav|x-ms-wmv|eot|svg|ttf|woff|woff2)$ {
expires 7d;
add_header Cache-Control "public";
}
# force download for ceratain file types
location ~* \.(?:fb2|mobi|mp3)$ {
add_header Content-Disposition "attachment";
}
...
}
Run Code Online (Sandbox Code Playgroud)
问题在于 .mp3 文件与两个位置块都匹配。仅使用第一个 (max-age)。我怎样才能同时拥有 .mp3 文件 - max-age和Content-Disposition “附件”?