tilezen / tapalcatl

Tapalcatl is a "metatile server", which attempts to serve individual tiles extracted from an archive in storage.
Other
14 stars 3 forks source link

Be stricter when writing HTTP timestamps #18

Closed zerebubuth closed 7 years ago

zerebubuth commented 7 years ago

The HTTP spec says:

All HTTP date/time stamps MUST be represented in Greenwich Mean Time (GMT), without exception. For the purposes of HTTP, GMT is exactly equal to UTC (Coordinated Universal Time). This is indicated in the first two formats by the inclusion of "GMT" as the three-letter abbreviation for time zone...

Tapalcatl is currently sending timestamps in RFC1123Z format, which does not exactly comply with the spec. Most servers and clients appear to be fine parsing it, but it causes a problem with Varnish, as the latter is very strict. This, in turn, causes Fastly to be unable to take advantage of "304 Not Modified" responses to If-Modified-Since conditional requests.

The Go http package provides a TimeFormat constant and says:

TimeFormat is the time format to use when generating times in HTTP headers. It is like time.RFC1123 but hard-codes GMT as the time zone. The time being formatted must be in UTC for Format to generate the correct format.

We should use the http.TimeFormat for generating times, and http.ParseTime for parsing them, to make sure we're standards-compliant and Varnish is happy.