Permalink
Browse files

Merge pull request #61 from chhh/develop

Change http response headers (cache-control changed, expires added)
  • Loading branch information...
igrigorik committed Mar 19, 2018
2 parents af00191 + 64a39b0 commit 2235bbf48849968f7ce254d2a753d254d15d197b
Showing with 6 additions and 3 deletions.
  1. +6 −3 ga-beacon.go
@@ -9,6 +9,7 @@ import (
"net/http"
"net/url"
"strings"
"time"
"appengine"
"appengine/delay"
@@ -105,11 +106,11 @@ func handler(w http.ResponseWriter, r *http.Request) {
// activate referrer path if ?useReferer is used and if referer exists
if _, ok := query["useReferer"]; ok {
if len(refOrg) != 0 {
referer := strings.Replace(strings.Replace(refOrg, "http://", "", 1), "https://", "", 1);
referer := strings.Replace(strings.Replace(refOrg, "http://", "", 1), "https://", "", 1)
if len(referer) != 0 {
// if the useReferer is present and the referer information exists
// the path is ignored and the beacon referer information is used instead.
params = strings.SplitN(strings.Trim(r.URL.Path, "/") + "/" + referer, "/", 2)
params = strings.SplitN(strings.Trim(r.URL.Path, "/")+"/"+referer, "/", 2)
}
}
}
@@ -144,7 +145,9 @@ func handler(w http.ResponseWriter, r *http.Request) {
}
if len(cid) != 0 {
w.Header().Set("Cache-Control", "private, no-store")
var cacheUntil = time.Now().Format(http.TimeFormat)
w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate, private")
w.Header().Set("Expires", cacheUntil)
w.Header().Set("CID", cid)
logHit(c, params, query, r.Header.Get("User-Agent"), r.RemoteAddr, cid)

0 comments on commit 2235bbf

Please sign in to comment.