Force browser to clear cache

后端 未结 17 2342
夕颜
夕颜 2020-11-22 05:04

Is there a way I can put some code on my page so when someone visits a site, it clears the browser cache, so they can view the changes?

Languages used: ASP.NET, VB.N

17条回答
  •  北荒
    北荒 (楼主)
    2020-11-22 05:54

    Updating the URL to the following works for me:

    /custom.js?id=1

    By adding a unique number after ?id= and incrementing it for new changes, users do not have to press CTRL + F5 to refresh the cache. Alternatively, you can append hash or string version of the current time or Epoch after ?id=

    Something like ?id=1520606295

提交回复
热议问题