0
votes

I'm serving static content using nginx. I'd like to support both Range requests and gzip compression.

Unfortunately, these two features are not compatible in nginx. Adding gzip on; to my config disables range requests.

Assuming I can't gzip everything, the next best option would be to enable gzip for all requests which lack a Range: header. Is this possible?

1

1 Answers

1
votes

The simpliest solution would be to add these lines next to every "gzip on" in your configuration:

if ($http_range) {
   gzip off;
}

Even though "if" is evil, in this case alternatives are even worse. If there are any at all.