有时在引用样式文件或资源文件时会加上版本号
例如:style.css?v=20140520
background: xxx.jpg?v=201140520
我是菜鸟,有这么几个困惑:
PHP中文网2017-04-25 09:05:56
We hope the engineer source code is written like this:
1 2 |
|
But the online code is like this:
1 2 |
|
The string of characters "_82244e91" is obtained by hashing based on the content of the a.js file. It will only change if the content of the file changes. Since the version sequence is written together with the file name instead of overwriting the file with the same name, the problems mentioned above will not occur. At the same time, there are other benefits of doing this:
The online a.js is not overwriting the file with the same name, but the redundancy of the file name + hash, so the static resources can be online first, and then the html page, and there is no gap problem;
When you encounter a problem and roll back the version, there is no need to roll back a.js, just roll back the page;
Since the static resource version number is the hash of the file content, permanent strong caching can be enabled for all static resources. Only files with updated content will be enabled
Cache invalidation, cache utilization greatly increased;
After modifying the static resources, new files will be generated online. One file corresponds to one version, so it will not be attacked in the form of CDN cache construction
Static resource version update and caching
某草草2017-04-25 09:05:56
世界只因有你2017-04-25 09:05:56