为什么这些文件的文件名具有随机字符串? [英] Why do these files have random strings for filenames?

查看:121
本文介绍了为什么这些文件的文件名具有随机字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到过这样的具有CSS和JS文件名的网站:

I've come across sites with CSS and JS filenames like this:

css_pbm0lsQQJ7A7WCCIMgxLho6mI_kBNgznNUWmTWcnfoE.css

是什么原因造成的,或者您为什么要这么做?

What's causing this or why would you do it?

以下每个答案中的一些都可能适用于这种情况,但是鉴于我在其上发现过的网站,提供/缓存方法似乎最为准确.

Some of each answer below could apply to this scenario, but given the sites I've found this on, serving/caching methods seems the most accurate.

推荐答案

版本化并确保提供了正确版本的静态资源. 如果您拥有一个高流量的网站并且为许多用户提供服务,则将有几层缓存:CDN,文件上的缓存头等.

Versioning and making sure that correct version of static resources is being served. If you have a high traffic website and you serve lots of users you will have several layers of caching: CDN, caching headers on files, etc.

有时很难使具有相同文件名的缓存无效.服务器可能会传递正确的标头,但客户端可能会忽略它们,并且仍会加载缓存的版本.提供不同的文件名可以防止这种情况,并确保您具有正确版本的css/js和其他静态资源.

Sometimes it can be hard invalidating the caches with the same filename. Server might pass the correct headers, but client might disregard them and still load cached version. Serving different file name prevents that and ensures that you have correct version of css/js and other static resources.

这篇关于为什么这些文件的文件名具有随机字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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