为什么某些CSS,JS文件的名称中包含随机数? [英] Why the names of some css, js files have random numbers in them?

查看:107
本文介绍了为什么某些CSS,JS文件的名称中包含随机数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

某些网站似乎具有 assets / app-02b4523sev8fsd56e.js之类的文件名。我注意到这些数字并没有改变,所以我认为这与安全性有关,但我不确定。

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?

推荐答案

这通常是为了破坏浏览器存储的缓存,以便文件的最新版本。已加载。每次更改文件时,通常也会更改该值。可以通过更改文件名和/或引用该文件的其他文件中的路径来手动完成此操作,或者可以通过某种方式以编程方式完成此操作。您也可能会像下面这样看到它,它可能还包含一个时间戳而不是像上面的哈希:

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.

这篇关于为什么某些CSS,JS文件的名称中包含随机数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆