Globalization, cache control and HTTP dates in browsers

I need an education about browsers and how they send dates in HTTP headers. My concern is that I cannot perform string comparisons if the user has a different browser or localization.

I currently have code similar to this for processing requests:

DateTime dt = getLastModified(someResourceHandle);
if(Request.Headers["If-Modified-Since"] == dt.ToString("R")/*RFC1123*/) { 
     // return HTTP 304 (Not Modified)
} else {
     getFullResource(someResourceHandle);
}

Purpose: I do not want it to crash.

So, I looked at the request headers from several browsers:

When I use IE, with English as my language:

Accept-Language: en-us
If-Modified-Since: Tue, 30 Jun 2009 15:52:19 GMT

When I use IE, and French (Belgium) - as my language (I would expect "mar" instead of "Tue"):

Accept-Language: fr-be
If-Modified-Since: Tue, 30 Jun 2009 15:52:19 GMT

No matter what I get from Firefox:

Accept-Language: en-us,en;q=0.5
If-Modified-Since: Tue, 30 Jun 2009 15:52:19 GMT

, , (RFC 1123), , ( Windows).

?

+3
1

, . HTTP, , , .

- Accept-Language ( , ).

+2

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


All Articles