Skip to content

Instantly share code, notes, and snippets.

@jonathaningram
Created February 9, 2016 05:26
Show Gist options
  • Save jonathaningram/49d6eacd50086f907080 to your computer and use it in GitHub Desktop.
Save jonathaningram/49d6eacd50086f907080 to your computer and use it in GitHub Desktop.
Google App Engine http.FileServer writes "Last-Modified:Thu, 01 Jan 1970 00:00:00 GMT" header

To see what happens with the std lib version,

go build && ./yourbin

Go to http://localhost:8080/ (make sure you force refresh if done in browser) and notice that the response header is OK:

Last-Modified:Tue, 09 Feb 2016 05:08:20 GMT

Now run the GAE version. You can't test this in dev, so you need to push it to prod.

It can be seen by going to http://gae-test-1133.appspot.com/ (make sure you force refresh if done in browser) and notice the bad header:

Last-Modified:Thu, 01 Jan 1970 00:00:00 GMT
application: gae-test-1133
module: default
version: 1
runtime: go
api_version: go1
handlers:
- url: /.*
script: _go_app
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title data-react-helmet="true">GAE test</title>
</head>
<body>
<h1>GAE test</h1>
<p>Counter: 4</p>
</body>
</html>
package main
import "net/http"
func init() {
http.Handle("/", http.StripPrefix("/", http.FileServer(http.Dir("dist"))))
}
// +build !appengine
package main
import (
"log"
"net/http"
)
func main() {
log.Println("starting server")
log.Fatal(http.ListenAndServe(":8080", nil))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment