Gzip Http Directive alters Javascript Files

Hello, I have a problem with a Caddy version 1.0.3, it is altering the content of my Javascript Files. Doing an analysis with firebug I found that Caddy returns in the Response Header the content-type as application/x-gzip, this is the response header:

HTTP/2.0 200 OK
Accept-Ranges: bytes
Content-Encoding: gzip
Date: Thu, 12 Sep 2019 19:38:24 GMT
Last-Modified: Tue, 07 Dec 2010 23:35:04 GMT
Server: Caddy
Vary: Accept-Encoding
Content-Type: application/x-gzip
Content-Length: 213
X-Firefox-Spdy: h2

I solved the problem temporally adding the “not” pointing to

gzip {
not /WebApp/resources/js
}

Is this a bug or is there something missing in my Caddyfile?

Thank you for your help.

Enrique Q.
CaddyIncorrectContent1

Hi @enrique-quinteros, welcome to the Caddy community.

What’s your full Caddyfile?

There might be something there that’s writing the response and not specifying the content type.

Within the gzip handler code there is a comment noting specifically that if the underlying handler does not write a Content-Type, some browsers will assume a content type of application/x-gzip and try to download the file. The gzip handler even attempts to detect the content type (using the Golang http standard library functions) in this event, to try and prevent this.

Hello @Whitestrake, I think you are correct about the underlying handler does not write a Content-Type only for javascript files. See the image attached. I am going to try sending a Content-Type from the application to Caddy and see if this works out.

I will let you know.

Thank you for your reply.CaddyIncorrectContent3

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.