@@ -55,6 +55,16 @@ func NewApp(params *param.Params) App {
5555 return App {params : params , server : nil , cache : cache }
5656}
5757
58+ func (app * App ) ShouldSkipCompression (filePath string ) bool {
59+ ext := strings .ToLower (filepath .Ext (filePath ))
60+ for _ , blocked := range app .params .NoCompress {
61+ if strings .ToLower (blocked ) == ext {
62+ return true
63+ }
64+ }
65+ return false
66+ }
67+
5868func (app * App ) CompressFiles () {
5969 if ! app .params .Gzip && ! app .params .Brotli {
6070 return
@@ -73,6 +83,10 @@ func (app *App) CompressFiles() {
7383 return nil
7484 }
7585
86+ if app .ShouldSkipCompression (filePath ) {
87+ return nil
88+ }
89+
7690 if info .Size () > app .params .Threshold {
7791 data , _ := os .ReadFile (filePath )
7892
@@ -231,6 +245,14 @@ func (app *App) HandlerFuncNew(w http.ResponseWriter, r *http.Request) {
231245 return
232246 }
233247
248+ if r .Header .Get ("Range" ) != "" || app .ShouldSkipCompression (requestedPath ) {
249+ if responseItem .ContentType != "" {
250+ w .Header ().Set ("Content-Type" , responseItem .ContentType )
251+ }
252+ http .ServeContent (w , r , responseItem .Name , responseItem .ModTime , bytes .NewReader (responseItem .Content ))
253+ return
254+ }
255+
234256 if slices .Contains (app .params .IgnoreCacheControlPaths , r .URL .Path ) || path .Ext (responseItem .Name ) == ".html" {
235257 w .Header ().Set ("Cache-Control" , "no-store" )
236258 } else {
0 commit comments