LoginSignup
3
1

More than 5 years have passed since last update.

.htaccessで特定のファイル(拡張子)に有効期限をつける

Last updated at Posted at 2017-12-19

GoogleのPageSpeed Insightで画像やファイルに有効期限をつけつけましょう的なことを言われた時に対応した内容をメモ。
.htaccessにファイルの拡張子で判断して有効期限を設定します。(max-ageの数値は秒:2592000秒=30日)

<Files ~ "\.(gif|jpe?g|png|svg|ico|otf|ttf|eot|woff)$">
Header set Cache-Control "max-age=2592000, public"
</Files>

<Files ~ "\.(css|js|html|gz)$">
Header set Cache-Control "max-age=86400, public"
</Files>
3
1
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
3
1