Make assets generation deterministic

By passing "-modtime 1" flag into go-bindata command it uses the same
unix timestamp (1) for every file in the fake filesystem. Thereby every
execution of "make assets" results in the same asset outputs if the
inputs were the same. This forces us to set the "Cache-Control"
attribute to "no-cache".
This commit is contained in:
Max Leonard Inden 2017-04-07 10:39:09 +02:00 committed by Max Inden
parent 8e4c29f5b8
commit c3850708c1
4 changed files with 11 additions and 9 deletions

View File

@ -58,8 +58,9 @@ docker:
assets:
@echo ">> writing assets"
-@$(GO) get -u github.com/jteeuwen/go-bindata/...
@go-bindata $(bindata_flags) -pkg ui -o ui/bindata.go ui/app/index.html ui/app/script.js
@go-bindata $(bindata_flags) -pkg deftmpl -o template/internal/deftmpl/bindata.go template/default.tmpl
# Using "-modtime 1" to make assets target deterministic. It sets all file time stamps to unix timestamp 1
@go-bindata $(bindata_flags) -modtime 1 -pkg ui -o ui/bindata.go ui/app/index.html ui/app/script.js
@go-bindata $(bindata_flags) -modtime 1 -pkg deftmpl -o template/internal/deftmpl/bindata.go template/default.tmpl
promu:
@GOOS=$(shell uname -s | tr A-Z a-z) \

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -40,6 +40,7 @@ func serveAsset(w http.ResponseWriter, req *http.Request, fp string) {
return
}
w.Header().Set("Cache-Control", "no-cache")
http.ServeContent(w, req, info.Name(), info.ModTime(), bytes.NewReader(file))
}