![](/img/trans.png)
[英]How to automatically add version numbers of md5 hash to javascript and css files in Visual Studio or use another way to force browser cache refresh?
[英]How to add md5 hash to js and css files with grunt?
我想在運行grunt
時將md5附加到所有js
和css
文件中,如下所示:
<link rel="stylesheet" type="text/css" href="style.css?md5hash" />
<script src="script.js?md5hash"></script>
那可能嗎? 我只能找到那些笨拙的插件,它們會自動重命名腳本文件本身並包含哈希值。 但是我想保持文件名始終相同,只需在index.html
更改引用md5名稱即可。
查看grun-cache-bust 。 它就是這樣做的。
聲明者:我只用過gulp-cache-bust,但我想這是同一回事。 它不僅會為您的腳本計算哈希和,還會搜索您的html文件並更新所有引用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.