mirror of https://github.com/jlelse/GoBlog
Add Cache-Control header for static files
This commit is contained in:
parent
abe1f39ea4
commit
fae7893f0b
|
@ -1,6 +1,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
@ -28,5 +29,6 @@ func allStaticPaths() (paths []string) {
|
|||
|
||||
// Gets only called by registered paths
|
||||
func serveStaticFile(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Cache-Control", fmt.Sprintf("public,max-age=%d,s-max-age=%d,stale-while-revalidate=%d", appConfig.Cache.Expiration, appConfig.Cache.Expiration/3, appConfig.Cache.Expiration))
|
||||
http.ServeFile(w, r, filepath.Join(staticFolder, r.URL.Path))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue