Skip to content

Instantly share code, notes, and snippets.

@macariojames
Created August 16, 2018 19:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save macariojames/602c923424060c9c41dae7b7918c0e77 to your computer and use it in GitHub Desktop.
Save macariojames/602c923424060c9c41dae7b7918c0e77 to your computer and use it in GitHub Desktop.
gzip compression with nginx
via Jack Wallen @jlwallen
-- This goes in /etc/ngnix/ngnix.conf
gzip on;
gzip_vary on;
gzip_min_length 10240;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml;
gzip_disable "MSIE [1-6]\.";
Here's an explanation for the configuration, line by line:
gzip on; - enables gzip compression
gzip_vary on: - tells proxies to cache both gzipped and regular versions of a resource
gzip_min_length 1024; - informs NGINX to not compress anything smaller than the defined size
gzip_proxied - compress data even for clients that are connecting via proxies (here we're enabling compression if: a response header includes the "expired", "no-cache", "no-store", "private", and "Authorization" parameters)
gzip_types - enables the types of files that can be compressed
gzip_disable "MSIE [1-6]\."; - disable compression for Internet Explorer versions 1-6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment