compression shouldn't compress binary and images by default #153
Replies: 3 comments 5 replies
-
Could you explain how it broke? I'm unaware of any reason that images and binaries can't/shouldn't be compressed. The client would avoid sending |
Beta Was this translation helpful? Give feedback.
-
When running directly in localhost it did work properly. But when I deployed it broke. I'm using caprover which is using nginx as the reverse proxy. Not sure if that changes anything but I'm using their base nginx config. https://github.com/caprover/caprover/blob/master/template/base-nginx-conf.ejs and https://github.com/caprover/caprover/blob/master/template/root-nginx-conf.ejs I temporarily reverted it. prabirshrestha/rblog@2541667 I was also surprised why compressing images wouldn't work when deploying. I'm wondering if it has something to do with the order? I'm currently using compression first and then caching headers. Wondering if it is something to do with ordering here. |
Beta Was this translation helpful? Give feedback.
-
Swapping the order doesn't seem to help. Log for broken* Connected to blog.prabir.me (66.94.115.178) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* CAfile: /etc/ssl/certs/ca-certificates.crt
* CApath: none
} [5 bytes data]
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
} [512 bytes data]
* TLSv1.3 (IN), TLS handshake, Server hello (2):
{ [122 bytes data]
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
{ [19 bytes data]
* TLSv1.3 (IN), TLS handshake, Certificate (11):
{ [4026 bytes data]
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
{ [264 bytes data]
* TLSv1.3 (IN), TLS handshake, Finished (20):
{ [52 bytes data]
* TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
} [1 bytes data]
* TLSv1.3 (OUT), TLS handshake, Finished (20):
} [52 bytes data]
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
* ALPN, server accepted to use h2
* Server certificate:
* subject: CN=blog.prabir.me
* start date: Nov 29 01:51:27 2021 GMT
* expire date: Feb 27 01:51:26 2022 GMT
* subjectAltName: host "blog.prabir.me" matched cert's "blog.prabir.me"
* issuer: C=US; O=Let's Encrypt; CN=R3
* SSL certificate verify ok.
* Using HTTP2, server supports multiplexing
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
} [5 bytes data]
* Using Stream ID: 1 (easy handle 0x55ef449969f0)
} [5 bytes data]
> GET /posts/sharing-public-domain-with-tailscale-and-internal-network-with-one-to-one-nat-using-opnsense/opnsense-firewall-enable-nat.png HTTP/2
> Host: blog.prabir.me
> user-agent: Mozilla/5.0 (X11; Linux x86_64; rv:96.0) Gecko/20100101 Firefox/96.0
> accept: image/avif,image/webp,*/*
> accept-language: en-US,en;q=0.5
> accept-encoding: gzip, deflate, br
> connection: keep-alive
> referer: https://blog.prabir.me/posts/sharing-public-domain-with-tailscale-and-internal-network-with-one-to-one-nat-using-opnsense/
> cookie: <----removed--->
> sec-fetch-dest: image
> sec-fetch-mode: no-cors
> sec-fetch-site: same-origin
> pragma: no-cache
> cache-control: no-cache
> te: trailers
>
{ [5 bytes data]
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
{ [57 bytes data]
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
{ [57 bytes data]
* old SSL session ID is stale, removing
{ [5 bytes data]
* Connection state changed (MAX_CONCURRENT_STREAMS == 128)!
} [5 bytes data]
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0< HTTP/2 200
< server: nginx
< date: Thu, 23 Dec 2021 00:30:49 GMT
< content-type: image/png
< content-encoding: br
< vary: Accept-Encoding
< x-request-id: FaDZdPPVTx
< last-modified: Thu, 23 Dec 2021 00:21:39 GMT
< etag: W/"1640218899.0-101503"
<
{ [3867 bytes data] Here is the broken file. https://www.dropbox.com/s/qbp7izxeu3vljme/opnsense-firewall-enable-nat.png?dl=0 I have disabled compression so my site is back to normal. |
Beta Was this translation helpful? Give feedback.
-
Just like how
HOST
,PORT
and others just works, it would be good ifcompression()
handler was a bit smarter to not compress images and binaries. It had one my site breaking when I deployed but not in localhost.Might be something like a logger style api that could provide custom condition on whether to compress or not would be good. By default it can compress text, js, css, html, json and others can force compress if they want.
Beta Was this translation helpful? Give feedback.
All reactions