Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Thomas <nick@gitlab.com>2017-07-03 18:22:50 +0300
committerNick Thomas <nick@gitlab.com>2017-07-03 18:36:16 +0300
commit8a8dedae07f2323bf74c9c8508ce4f8ff67bc7db (patch)
tree581971be54469c5ac85fb2faab1ca9ba6f0c8bee /domain.go
parent62409e8cb2dc856134587c3479f0a3da8b3da53b (diff)
Add simple Cache-Control and Expires headers to 200 OK responses
Diffstat (limited to 'domain.go')
-rw-r--r--domain.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/domain.go b/domain.go
index 6d24c17a..45e59f94 100644
--- a/domain.go
+++ b/domain.go
@@ -11,6 +11,7 @@ import (
"path/filepath"
"strconv"
"strings"
+ "time"
"gitlab.com/gitlab-org/gitlab-pages/internal/httputil"
)
@@ -72,6 +73,10 @@ func (d *domain) serveFile(w http.ResponseWriter, r *http.Request, origPath stri
return err
}
+ // Set caching headers
+ w.Header().Set("Cache-Control", "max-age=600")
+ w.Header().Set("Expires", time.Now().Add(10*time.Minute).Format(time.RFC1123))
+
fmt.Println("Serving", fullPath, "for", r.URL.Path)
// ServeContent sets Content-Type for us