magneticow: web: enable caching static resources for 24 hours
This commit is contained in:
parent
74ca0cac13
commit
2328087edb
@ -30,7 +30,9 @@ func rootHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
// TODO: we might as well move torrents.html into static...
|
// TODO: we might as well move torrents.html into static...
|
||||||
func torrentsHandler(w http.ResponseWriter, r *http.Request) {
|
func torrentsHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
data := mustAsset("templates/torrents.html")
|
data := mustAsset("templates/torrents.html")
|
||||||
w.Header().Set("Content-Type", http.DetectContentType(data))
|
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||||
|
// Cache static resources for a day
|
||||||
|
w.Header().Set("Cache-Control", "max-age=86400")
|
||||||
w.Write(data)
|
w.Write(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,7 +77,9 @@ func torrentsInfohashHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
// TODO: we might as well move statistics.html into static...
|
// TODO: we might as well move statistics.html into static...
|
||||||
func statisticsHandler(w http.ResponseWriter, r *http.Request) {
|
func statisticsHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
data := mustAsset("templates/statistics.html")
|
data := mustAsset("templates/statistics.html")
|
||||||
w.Header().Set("Content-Type", http.DetectContentType(data))
|
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||||
|
// Cache static resources for a day
|
||||||
|
w.Header().Set("Cache-Control", "max-age=86400")
|
||||||
w.Write(data)
|
w.Write(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,5 +153,7 @@ func staticHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
contentType = http.DetectContentType(data)
|
contentType = http.DetectContentType(data)
|
||||||
}
|
}
|
||||||
w.Header().Set("Content-Type", contentType)
|
w.Header().Set("Content-Type", contentType)
|
||||||
|
// Cache static resources for a day
|
||||||
|
w.Header().Set("Cache-Control", "max-age=86400")
|
||||||
w.Write(data)
|
w.Write(data)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user