为什么图片及之后查询字符串; css文件? [英] Why querystrings after images & css files?

查看:62
本文介绍了为什么图片及之后查询字符串; css文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到的各种网站查询字符串后面的图像和CSS文件的数字。当我看到(通过Chrome开发者)来源$ C ​​$ C,缓存的CSS文件和图像没有在他们的名字查询字符串的数量。我也看到在哪里的查询字符串数量的变化,当我刷新页面的网站。

I have seen on various sites a querystring followed by a numbers for images and css files. When I look at the source code (via Chrome Developer), the cached css files and images do not have the number in the query string in their names. I have also seen on sites where the number changes in the querystrings when I refresh the page.

作为例子:

myimage.jpg?NUM = 12345

myimage.jpg?num=12345

myStyles.css?NUM = 82943

myStyles.css?num=82943

刷新后:

myimage.jpg?NUM = 67948

myimage.jpg?num=67948

myStyles.css?NUM = 62972

myStyles.css?num=62972

任何人都可以向我解释什么可能是这些查询字符串的短期跟踪的目的是什么?

Can anyone explain to me what could possibly be the purpose of these querystrings short of tracking?

推荐答案

很多时候,开发人员可以使用随机数(或版本号)的查询字符串,迫使浏览器请求一个新的副本,避免因为请求这些文件的缓存每一次都是不同的。

Often times developers use those query strings with random numbers (or version numbers) to force the browser to request a fresh copy and avoid caching of those files since the request is different each time.

所以,如果你有一个文件 /image.png 但它是一个生成的图像,比如可能是一个验证码什么的,你可以用随机数的查询字符串遵循它 /image.png?399532 该浏览器会那么不拉 image.png 从其缓存,而是将下载新的复制从服务器。

So if you have a file /image.png but it is a generated image, like perhaps a captcha or something, you could follow it with a random number querystring /image.png?399532 which the browser would then not pull image.png from its cache, but instead will download a fresh copy from the server.

这篇关于为什么图片及之后查询字符串; css文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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