gpt4 book ai didi

css - 与问号和数值链接的样式表

转载 作者:太空宇宙 更新时间:2023-11-03 17:30:11 25 4
gpt4 key购买 nike

我可以看到这个 site.com/assets/css/screen.css?954d46d92760d5bf200649149cf28ab453c16e2b这个随机字母数字值问号是什么?我认为它没有任何使用值(value)或者它是关于什么的?编辑:在刷新页面上,字母数字值也是相同的。

最佳答案

这是为了防止浏览器缓存CSS。当某些浏览器(特别是 Internet Explorer)请求 CSS 时,浏览器将拥有 CSS 的本地副本。

当向服务器发出请求时:

site.com/assets/css/screen.css?skdjhfk
site.com/assets/css/screen.css?5sd4f65
site.com/assets/css/screen.css?w4rtwgf
site.com/assets/css/screen.css?helloWd

site.com 的服务器只能看到:

site.com/assets/css/screen.css

并给出最新版本。但是当 HTML 页面请求浏览器获取 CSS 时:site.com/assets/css/screen.css,这是第一次从 site.com 服务器。发送下一个请求时,内容可能同时更改的可能性有很多。所以程序员一般会加一个?and-some-random-text,称为Query String。这将强制浏览器从服务器获取新副本。

一些更详细的解释:

It is a well known problem that IE caches too much of html, even when giving a Cache-Control: no-cache or Last-Modified header to everypage.

This behaiviour is really troubling when working with querystrings to get dynamic information, as IE considers it to be the same page (i.e.: http://example.com/?id=10) and serves the cached version.

I've solved it adding either a random number or a timestring to the querystring (as others have done) like this http://example.com/?id=10&t=2009-08-06_13:12:56 that I just ignore serverside.

Is there a better option? Is there another, cleaner way to acomplish this? I'm aware that POST isn't cached, but it is semanticaly correct to use GET here.

引用:Random Querystring to avoid IE caching

关于css - 与问号和数值链接的样式表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30750763/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com