HTTP If-Modified-Since with milliseconds

Say I get an object from a REST web service, and that object has a timestamp. This timestamp has a millisecond component. The next time I ask for the same object, I don’t want it to return unless it has changed, so I use the If-Modified-Since header. But the date in this header should not even have milliseconds. If I round the timestamp, I will always return the object back, as if it always changed. If I get around it, I risk losing some updates. Is the If-Modified-Since header completely useless to me in this case, or am I missing something?

+6
source share
1 answer

A service that sends a timestamp with milliseconds is not HTTP compatible. Last-Modified MUST be sent as an HTTP date, which Β§3.3.1 indicates very clearly:

 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 (eg, 02 Jun 1982) date2 = 2DIGIT "-" month "-" 2DIGIT ; day-month-year (eg, 02-Jun-82) date3 = month SP ( 2DIGIT | ( SP 1DIGIT )) ; month day (eg, 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" 

Enter the error in the service you are using. Invalid send Last-Modified or If-Modified-Since using milliseconds.

If second second accuracy is important, it may be more appropriate to use entity tags ( ETag ) .

+9
source

Source: https://habr.com/ru/post/953103/


All Articles