Why the names of some css, js files have random numbers in them?

你离开我真会死。 提交于 2019-12-21 17:56:27

问题


Some websites seem to have file names such as 'assets/app-02b4523sev8fsd56e.js'. I have noticed that these numbers do not change though, so I thought it has something to do with security but I am not sure. Is there any reason behind this?


回答1:


This is normally to break caches stored by the browser so that the latest version of a file is loaded. Every time a file is changed this value will normally be changed also. This can be done manually by changing the filename and/or the paths in other files referencing this file, or this can be done programatically in some way. You may also see this done like the following and it may also contain a timestamp rather than a hash like the above:

assets/scripts.js?v=20150611190618

This is often referred to as a 'cache-buster' amongst other names.



来源:https://stackoverflow.com/questions/30788200/why-the-names-of-some-css-js-files-have-random-numbers-in-them

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!