Why the names of some css, js files have random nu

2019-05-06 19:51发布

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条回答
祖国的老花朵
2楼-- · 2019-05-06 20:10

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.

查看更多
登录 后发表回答