etag

HTTP协议缓存

左心房为你撑大大i 提交于 2019-11-27 05:00:58
缓存的概念 缓存这个东西真的是无处不在, 有浏览器端的缓存, 有服务器端的缓存,有代理服务器的缓存, 有ASP.NET页面缓存,对象缓存。 数据库也有缓存, 等等。 http中具有缓存功能的是浏览器缓存,以及缓存代理服务器。 http缓存的是指:当Web请求抵达缓存时, 如果本地有“已缓存的”副本,就可以从本地存储设备而不是从原始服务器中提取这个文档。 缓存的好处 缓存的好处是显而易见的, 好处有, 1. 减少了冗余的数据传输,节省了网费。 2. 减少了服务器的负担, 大大提高了网站的性能 3. 加快了客户端加载网页的速度 Fiddler可以方便地查看缓存的header Fiddler中把header都分门别类的放在一起,这样方便查看。 如何判断缓存新鲜度 Web服务器通过2种方式来判断浏览器缓存是否是最新的。 第一种, 浏览器把缓存文件的最后修改时间通过 header ”If-Modified-Since“来告诉Web服务器。 第二种, 浏览器把缓存文件的ETag, 通过header "If-None-Match", 来告诉Web服务器。 通过最后修改时间, 来判断缓存新鲜度 1. 浏览器客户端想请求一个文档, 首先检查本地缓存,发现存在这个文档的缓存, 获取缓存中文档的最后修改时间,通过: If-Modified-Since, 发送Request给Web服务器。 2.

HTTP: Generating ETag Header

不想你离开。 提交于 2019-11-27 04:29:29
问题 How do I generate an ETag HTTP header for a resource file? 回答1: An etag is an arbitrary string that the server sends to the client that the client will send back to the server the next time the file is requested. The etag should be computable on the server based on the file. Sort of like a checksum, but you might not want to checksum every file sending it out. server client <------------- request file foo file foo etag: "xyz" --------> <------------- request file foo etag: "xyz" (what the

How to prevent request that returns 304

我的未来我决定 提交于 2019-11-27 03:19:26
When does a browser NOT make a request to the server for a file? In other words, I have a JavaScript file being served. Its HTTP response header has an ETag , Cache-Control: public , and Expires: Tue, 19 Jan 2038 03:14:07 GMT . The server is returning a 304 after the browser cache has been primed. My question is, why is the browser even checking with the server and getting a 304 in the first place? I don't want the browser to go ask if there's a new version—it should load directly from browser cache without checking for modifications with the server serving the script. What combination of HTTP

Syntax for ETag?

*爱你&永不变心* 提交于 2019-11-27 03:05:05
问题 Redbot reports that my webpage has invalid header: The ETag header's syntax isn't valid. My headers are set to: ETag: 4ae413bd Why is it invalid? What is the syntax for an ETag? 回答1: Try ETag: "4ae413bd" . The value of an ETag must follow the ABNF form: entity-tag = [ weak ] opaque-tag weak = "W/" opaque-tag = quoted-string quoted-string = ( <"> *(qdtext | quoted-pair ) <"> ) qdtext = <any TEXT except <">> quoted-pair = "\" CHAR CHAR = <any US-ASCII character (octets 0 - 127)> TEXT = <any

NSURLCache and ETags

旧时模样 提交于 2019-11-27 02:19:02
问题 Does NSURLCache transparently handle ETags received by server? I mean: does it automatically store ETags for each URL request and then send the appropriate If-None-Match when a request to the same URL is submitted? Or do I have to manage it by myself? 回答1: yes it does handle it transparently if you set its cache mode: NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:urlString] cachePolicy: NSURLRequestUseProtocolCachePolicy timeoutInterval:60]; note: you

IIS 7.5 remove etag headers from response

ぐ巨炮叔叔 提交于 2019-11-27 00:11:14
问题 I know this question has been asked alot of times, however most of them were in 2009-2010. I am pretty sure a while back a project I was working on removed them, however I cannot find any way to remove them at the moment. So has there been any advances in this field? It seems crazy that microsoft has made IIS to not be able to easily configure these headers. Currently have tried: Adding a blank etag header to the web.config Adding an etag with quotes inside to the web.config Adding a blank

浏览器缓存

懵懂的女人 提交于 2019-11-26 22:43:00
---恢复内容开始--- 缓存对于前端性能优化来说是一个很重要的点,良好的缓存策略可以降低资源的重复加载,提高网页的整体加载速度 缓存主要有两种: 强缓存 协商缓存 1、强缓存   缓存期间不需要请求,status code为200   强缓存有两种实现方式: Expires:Wed,22 Oct 2019 08:41:00 GMT Cache-Control:max-age=30   区别:   1)Expires时HTTP/1.0的产物,表示缓存的过期时间,但是受限于本地时间,可能会造成缓存失效   2)Cache-Control出现于HTTP/1.1,优先级高于Expores,表示资源回在30s后过去 2、协商缓存   如果强缓存过期了,我们可以使用协商缓存解决问题。   协商缓存需要请求,如果缓存有效会返回304   协商缓存需要客户端和服务端共同实现   协商缓存有两种实现方式: Last-Modified和If-Modified-Since:Last-Modified表示本地文件最后修改日期,If-Modified-Since会将Last-Modifed的值发送给服务器,询问服务器在该日期后资源是否有修改,如果有就会将新资源发送回来。(但若在本地打开缓存文件,就会造成Last-Modified被修改) ETag和If-None-Match:ETag类似于文件指纹,If

How to prevent request that returns 304

戏子无情 提交于 2019-11-26 12:08:23
问题 When does a browser NOT make a request to the server for a file? In other words, I have a JavaScript file being served. Its HTTP response header has an ETag , Cache-Control: public , and Expires: Tue, 19 Jan 2038 03:14:07 GMT . The server is returning a 304 after the browser cache has been primed. My question is, why is the browser even checking with the server and getting a 304 in the first place? I don\'t want the browser to go ask if there\'s a new version—it should load directly from

详解HTTP的缓存机制与原理

杀马特。学长 韩版系。学妹 提交于 2019-11-25 19:11:19
详解HTTP的缓存机制与原理 概述 缓存的重要性不言而喻了,通过网络请求资源缓慢并且大大的降低了客户端的用户体验,增添了服务端的负担。很多短期之内不会经常发生变化的资源文件没必要每次访问都向服务端进行数据请求,而缓存策略的使用就是为了改善客户端的呈现时间,降低服务端的负担。 对于HTTP的缓存机制来说,策略体现在HTTP的头部信息的字段上,而这些策略 根据是否需要重新向服务器端发起请求 可以分为 强缓存和协商缓存 两大类。接下来用UML时序图的形式来呈现这两大类缓存策略的大体过程。 强缓存 强缓存紧密联系着一个缓存时间期限,当浏览器请求资源的时候会查看缓存中的资源是否存在并且确定该缓存的资源是否过了“保质期”,若没有超过保质期则将取得缓存中的资源进行下一步处理 协商缓存 可见协商缓存无论如何都会和服务器交互,比较强缓存稍微要复杂一点,但是二者是相辅相成并且可以共同存在的,强缓存优先级较高,意味着请求一个资源时会先比较强缓存的字段,如果命中则不会再执行接下来的协商缓存的过程。 介绍两类缓存相关HTTP header相关字段的控制实现了 细节 1.强缓存 与强缓存相关的HTTP header 的字段有两个 Expires以及Cache-Control Expires expires 字段规定了缓存的资源的过期时间,在此时间之前,缓存中的资源都是有效的,该字段的 value