在css包含url的结尾处的问号是什么? [英] What does the question mark at then end of a css include url do?

查看:230
本文介绍了在css包含url的结尾处的问号是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到,在某些网站(包括SO)上,CSS的链接将如下所示:

I've noticed that on some websites (including SO) the link to the CSS will look like:

<link rel="stylesheet" href="http://sstatic.net/so/all.css?v=6638"> 

我会说它可以安全地假设?v = 6638 告诉浏览器加载css文件的版本6638。但是我可以在我的网站上这样做,可以通过更改数字来包含不同版本的CSS文件吗?

I would say its safe to assume that ?v=6638 tells the browser to load version 6638 of the css file. But can I do this on my websites and can I include different versions of my CSS file just by changing the numbers?

推荐答案

使用不同的查询字符串加载 all.css ,以便如果版本6637已经缓存在您的计算机上,您将获得一个新的(6638)。更改该数字(在这种情况下)不会给您一个不同的文件。

That loads all.css with a different query string so that if version 6637, for instance, is already cached on your machine, you'll get the new one (6638). Changing that number (in this case) will not give you a different file.

这只是一个缓存技巧,所以他们可以发送文件没有到期(即您从不必再次请求),因为当确实更改时,文件名会更改。

This is just a cache trick so they can send the file down with no expiration (i.e. you never have to ask for it again), because when it does change, the "file name", changes.

也就是说,您可以 使其加载基于查询字符串参数的不同版本。这样做会稍微不平凡,类似于当您向此网页的网址传递不同的问题ID时,如何得到不同的问题。

That said, you could make it so you load a different version based on the query string parameter. Doing so would be slightly non-trivial and akin to how you get different questions when you pass a different question ID to the URL of this page.

这篇关于在css包含url的结尾处的问号是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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