If-Modified-Since HTTP header passed by IE9 includes length?

五迷三道 提交于 2020-01-24 04:00:16

问题


Please clarify this weird If-Modified-Since header passed by IE9

In my ASP.NET 4.0 web app, I've got a generic handler (.ashx) that serves images stored in the DB. In the interest of efficiency, I'm handling some caching-related headers and passing cache information.

I'm getting DateTime parse errors moderately frequently from trying to parse the If-Modified-Since header contents, usually from IE9. Turns out it's sending something like this:

Mon, 28 Nov 2011 16:34:52 GMT; length=8799

I'm handling that by using a regular expression to strip out the last part. But I'm curious: what length is it referring to, and what use is it? Is it the size of the cached data for the requested URL?


回答1:


According to an old post on the Squid proxy mailing list:

The length parameter to If-Modified-Since is a Netscape extension of HTTP/1.0, meant to improve the accuracy of If-Modified-Since in case a document is updated twice in the same second.

HTTP/1.1 solved the same problem in a better way via the ETag header and If-None-Match.

I'm guessing that IE adapted this extension at some point and have left it in.




回答2:


This seems to be an old Netscape extension of the header field (see an ancient discussion on http-wg); even though it seems to actually be against both HTTP/1.0 and HTTP/1.1 specifications (the idea was (functionally) replaced with the ETag header). No idea if/why IE9 sends it and under what specific conditions (I would guess only a specific combination of caching headers triggers it).

I guess the best solution would be to drop anything after a semicolon, which is normally used in HTTP to separate extension parameters in headers (see e.g. the Accept header).



来源:https://stackoverflow.com/questions/12626699/if-modified-since-http-header-passed-by-ie9-includes-length

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!