mirror of
https://github.com/writefreely/writefreely
synced 2024-09-20 13:41:54 +00:00
Move cacheControl func into handle.go file
This commit is contained in:
parent
3f36ede885
commit
1b1d3064c9
2 changed files with 7 additions and 8 deletions
8
cache.go
8
cache.go
|
@ -11,7 +11,6 @@
|
||||||
package writefreely
|
package writefreely
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
@ -68,10 +67,3 @@ func GetPostsCache(userID int64) *[]PublicPost {
|
||||||
}
|
}
|
||||||
return pci.Posts
|
return pci.Posts
|
||||||
}
|
}
|
||||||
|
|
||||||
func cacheControl(next http.Handler) http.Handler {
|
|
||||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
||||||
w.Header().Set("Cache-Control", "public, max-age=604800, immutable")
|
|
||||||
next.ServeHTTP(w, r)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
|
@ -926,3 +926,10 @@ func sendRedirect(w http.ResponseWriter, code int, location string) int {
|
||||||
w.WriteHeader(code)
|
w.WriteHeader(code)
|
||||||
return code
|
return code
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func cacheControl(next http.Handler) http.Handler {
|
||||||
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
w.Header().Set("Cache-Control", "public, max-age=604800, immutable")
|
||||||
|
next.ServeHTTP(w, r)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue