We're running Nginx 0.7.65[-1ubuntu2.3]. I've just noticed that when serving local static files using an alias
directive and gzip on
, the Content-Length
header is not getting sent. Since it's serving files from the local filesystem, it shouldn't have any problem getting the length. How can I force Nginx to send a Content-Length
header with these files?
Nginx Content-Length Header for Static Files with Gzip – How to Force
gzipnginxstatic-content
Related Topic
- Nginx – Disable caching when serving static files with Nginx (for development)
- Nginx – PHP content-length header not specifying size for the forced download
- Nginx – Serving static files with nginx over NFS
- Gzip Compression Efficiency – Why Gzip Varies in IIS
- Nginx + uwsgi – what is serving static files
- NGINX Not Serving “Fast” Stale Content with proxy_cache_background_update
Best Answer
It turns out that when using dynamic Gzip then the
Content-Length
header is not sent, as theTransfer-Encoding
ischunked
. Pre-compressing my files and switching to static Gzip allows Nginx to know ahead of time the file size and send an appropriateContent-Length
header.