css include url 末尾的问号有什么作用? [英] What does the question mark at then end of a css include url do?

查看:25
本文介绍了css include 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 传递到此页面的 URL 时,您如何得到不同的问题.

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 include url 末尾的问号有什么作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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