mirror of
https://github.com/status-im/fathom.git
synced 2025-03-01 03:20:27 +00:00
set 'Tk: N' header on resources loaded by client. #65
This commit is contained in:
parent
42cd00b8cd
commit
844c5996ff
@ -122,11 +122,16 @@ func (api *API) NewCollectHandler() http.Handler {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// don't you cache this
|
// indicate that we're not tracking user data, see https://github.com/usefathom/fathom/issues/65
|
||||||
|
w.Header().Set("Tk", "N")
|
||||||
|
|
||||||
|
// headers to prevent caching
|
||||||
w.Header().Set("Content-Type", "image/gif")
|
w.Header().Set("Content-Type", "image/gif")
|
||||||
w.Header().Set("Expires", "Mon, 01 Jan 1990 00:00:00 GMT")
|
w.Header().Set("Expires", "Mon, 01 Jan 1990 00:00:00 GMT")
|
||||||
w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
|
w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
|
||||||
w.Header().Set("Pragma", "no-cache")
|
w.Header().Set("Pragma", "no-cache")
|
||||||
|
|
||||||
|
// response
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
|
|
||||||
// 1x1 px transparent GIF
|
// 1x1 px transparent GIF
|
||||||
|
@ -29,10 +29,18 @@ func (api *API) Routes() *mux.Router {
|
|||||||
|
|
||||||
// static assets & 404 handler
|
// static assets & 404 handler
|
||||||
box := packr.NewBox("./../../assets/build")
|
box := packr.NewBox("./../../assets/build")
|
||||||
r.Path("/tracker.js").Handler(serveFileHandler(&box, "js/tracker.js"))
|
r.Path("/tracker.js").Handler(serveTrackerFile(&box))
|
||||||
r.Path("/").Handler(serveFileHandler(&box, "index.html"))
|
r.Path("/").Handler(serveFileHandler(&box, "index.html"))
|
||||||
r.PathPrefix("/assets").Handler(http.StripPrefix("/assets", http.FileServer(box)))
|
r.PathPrefix("/assets").Handler(http.StripPrefix("/assets", http.FileServer(box)))
|
||||||
r.NotFoundHandler = NotFoundHandler(&box)
|
r.NotFoundHandler = NotFoundHandler(&box)
|
||||||
|
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func serveTrackerFile(box *packr.Box) http.Handler {
|
||||||
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
w.Header().Set("Tk", "N")
|
||||||
|
next := serveFile(box, "js/tracker.js")
|
||||||
|
next.ServeHTTP(w, r)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user