LoginSignup
7
6

More than 5 years have passed since last update.

jsファイルの更新が反映されない

Last updated at Posted at 2018-06-11

jsファイルの更新がサーバーで反映されない

キャッシュが残っていると更新したjsファイルの変更が反映されない

<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-Control" content="no-cache">
<meta http-equiv="Expires" content="0">

htmlではmetaタグを使用しキャッシュを無効にすればいい
jsファイルではこの方法が使用できないので他の方法を探すことに

Cache Busting

ファイルにクエリー文字列を付加することで毎回新しいファイルとして扱わせることを海外ではCache Bustingと呼ぶらしい

<script src="./js/input.js?date=yyyymmddhhss"></script>

このようなクエリー文字列を追加すれば毎回読み込んでくれる
文字列を自動生成するメソッドを追加しないといけないけれど

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