Cache control assets with ETag based on commit

MustCompiles belong in constants


> On Dec 23, 2014, at 4:25 PM, Jordan Liggitt <notifications@github.com> wrote:
> 
> In pkg/assets/handlers.go:
> 
> > +		h.ServeHTTP(&gzipResponseWriter{Writer: gz, ResponseWriter: w}, r)
> > +	})
> > +}
> > +
> > +func generateEtag(r *http.Request, version string, varyHeaders []string) string {
> > +	varyHeaderValues := ""
> > +	for _, varyHeader := range varyHeaders {
> > +		varyHeaderValues += r.Header.Get(varyHeader)
> > +	}
> > +	return fmt.Sprintf("W/\"%s_%s\"", version, hex.EncodeToString([]byte(varyHeaderValues)))
> > +}
> > +
> > +func CacheControlHandler(version string, h http.Handler) http.Handler {
> > +	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
> > +		vary := w.Header().Get("Vary")
> > +		var varyHeaders []string
> varyHeaders := []string{}
> if vary != "" {
>   varyHeaders = regexp.MustCompile("\\s*,\\s*").Split(vary, -1)
> }
> —
> Reply to this email directly or view it on GitHub.
>