LoginSignup
0
0

More than 1 year has passed since last update.

Nginxでgzip圧縮を有効にする

Posted at

JSやCSSなどの転送量を減らし、表示速度を高めるための手法としてgzip圧縮があります。
Nginxでgzip圧縮する方法のメモ。

設定

Nginxの設定ファイルでhttp,serverディレクティブなどのどこかに以下を追加。

gzip  on;
gzip_types  <content type>;

text/htmlはデフォルトで圧縮される。それ以外のcontent-type、例えばjsを圧縮したければ、gzip_typesで追加。*を使うと全てのタイプで有効になる。

gzip  on;
gzip_types  application/javascript;

設定の確認

設定が反映されるとchromeのdevtoolでcontent-encoding: gzipとなっているのが確認できる。

スクリーンショット_2021-07-07_11_48_38.png

参考

0
0
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
0
0