假设我从 REST Web 服务获取了一个对象,并且该对象有一个时间戳。这个时间戳有一个毫秒部分。下次我请求同一个对象时,我不希望它被返回,除非它已经改变,所以我使用 If-Modified-Since 标头。但是该标题中的日期甚至不应该有毫秒。如果我将时间戳四舍五入,我将始终将对象取回,就好像它总是被修改过一样。如果我把它四舍五入,我可能会错过一些更新。在这种情况下,If-Modified-Since 标头对我完全没用,还是我错过了什么?
问问题
2483 次
1 回答
14
以毫秒为单位发送时间戳的服务不符合 HTTP。 Last-Modified
必须作为§3.3.1明确规定的HTTP 日期发送:
HTTP-date = rfc1123-date | rfc850-date | asctime-date rfc1123-date = wkday "," SP date1 SP time SP "GMT" rfc850-date = weekday "," SP date2 SP time SP "GMT" asctime-date = wkday SP date3 SP time SP 4DIGIT date1 = 2DIGIT SP month SP 4DIGIT ; day month year (e.g., 02 Jun 1982) date2 = 2DIGIT "-" month "-" 2DIGIT ; day-month-year (e.g., 02-Jun-82) date3 = month SP ( 2DIGIT | ( SP 1DIGIT )) ; month day (e.g., Jun 2) time = 2DIGIT ":" 2DIGIT ":" 2DIGIT ; 00:00:00 - 23:59:59 wkday = "Mon" | "Tue" | "Wed" | "Thu" | "Fri" | "Sat" | "Sun" weekday = "Monday" | "Tuesday" | "Wednesday" | "Thursday" | "Friday" | "Saturday" | "Sunday" month = "Jan" | "Feb" | "Mar" | "Apr" | "May" | "Jun" | "Jul" | "Aug" | "Sep" | "Oct" | "Nov" | "Dec"
向您正在使用的服务提交错误。发送Last-Modified
或If-Modified-Since
以毫秒为单位无效。
于 2013-09-03T23:54:38.927 回答