Created
August 16, 2018 19:09
-
-
Save macariojames/602c923424060c9c41dae7b7918c0e77 to your computer and use it in GitHub Desktop.
gzip compression with nginx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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