Prevent javascript from being cached in browser

2019-08-06 13:14发布

I'm currently working on a webapp and the Javascript is revised fairly often. However, the changes don't occur until the browser cache is refreshed manually. Is there a way to implement cache-refreshing automatically through code for Chrome? Thanks.

1条回答
兄弟一词,经得起流年.
2楼-- · 2019-08-06 14:02

You can put something like ?2352352 at the end of your JS file. So something like

<script src='myfile.js?20457207'></script>

Where the number randomizes, forcing the browser to think it's a different file.

查看更多
登录 后发表回答