1
0

More than 5 years have passed since last update.

millisecのgetリクエストをキャッシュさせない。

Posted at

urlのパラメータ末尾にランダムな値を入れる。

//ex) superagent
return req.get(url).set(...)
   .query({_:Date.now() +''+performance.now().toString().replace('.','') }) //no-chash
   .then(res=>res.body)

秒単位でも問題ない場合

.query({_:Date.now()})

Date系がない場合

.query({_:Math.floor(Math.random()*10000000000000)})

更新したデータによってcacheの切り替えをする場合。

//hashが被ればcacheデータを使ってくれる。ブラウザなどに依存。
.query({_:md5(newdata)})
1
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
1
0