LoginSignup
4
4

More than 5 years have passed since last update.

[nginx] Mime タイプごとに expires 設定

Posted at

httpディレクティブに map ディレクティブを追加

nginx.conf
map $sent_http_content_type $expires {
    default                off;
    ~image/                max;
    ~audio/                max;
    ~video/                max;
    text/css               30d;
    text/javascript        30d;
    application/javascript 30d;
    application/pdf        max;
}

mime タイプは正規表現でも書ける。
server ディレクティブに以下を追加

nginx/conf.d/server.conf
server {
 expires $expires;
 # :
}

これで安心

4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4