dont gzip a gzip and .js.gz has contenttype javascript
parent
5a2340cc1d
commit
2d1170f158
|
|
@ -82,6 +82,9 @@ func SetContentTypeIfMedia(w http.ResponseWriter, r *http.Request) {
|
||||||
case ".gz":
|
case ".gz":
|
||||||
w.Header().Set("Content-Encoding", "gzip")
|
w.Header().Set("Content-Encoding", "gzip")
|
||||||
v = "application/gzip"
|
v = "application/gzip"
|
||||||
|
if path.Ext(r.URL.Path) == ".js.gz" {
|
||||||
|
v = "application/javascript"
|
||||||
|
}
|
||||||
case ".gif":
|
case ".gif":
|
||||||
v = "image/gif"
|
v = "image/gif"
|
||||||
case ".htm,":
|
case ".htm,":
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,9 @@ type GZipResponseWriter struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func Can(r *http.Request) bool {
|
func Can(r *http.Request) bool {
|
||||||
|
if strings.HasSuffix(r.URL.Path, ".gz") {
|
||||||
|
return false
|
||||||
|
}
|
||||||
encodings, _ := r.Header["Accept-Encoding"]
|
encodings, _ := r.Header["Accept-Encoding"]
|
||||||
for _, encoding := range encodings {
|
for _, encoding := range encodings {
|
||||||
items := strings.Split(encoding, ",")
|
items := strings.Split(encoding, ",")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue