Description
The check for timestamp validity in http.ServeFile()
is not sufficient to detect invalid timestamps on unix systems. On App Engine, all files have the modified date set to 1 Jan 1970 (the unix epoch). In this environment, http.ServeFile()
serves files with the header
Last-Modified: Thu, 01 Jan 1970 00:00:00 GMT
regardless of the actual last modified date of the file. This is a problem because it means files may be cached on client browsers forever. This happens because the client may request the file with
GET /file.html HTTP/1.1
If-Modified-Since: Thu, 01 Jan 1970 00:00:00 GMT
Then App Engine will replies with
304 Not Modified.
In the file src/net/http/fs.go
, there is an attempt to check if the modified timestamp is valid by calling Time.IsZero()
but this checks if the date is Jan 1, 1 AD, which is always false for all unix timestamps. It probably makes sense to add an explicit check for unix timestamp == 0
to serve ServeFile
and convert this to Time.Zero
.