Skip to content

Instantly share code, notes, and snippets.

@mgmgpyaesonewin
Created February 23, 2022 03:28
Show Gist options
  • Save mgmgpyaesonewin/a3a5980637676ff865125b6fecab1dac to your computer and use it in GitHub Desktop.
Save mgmgpyaesonewin/a3a5980637676ff865125b6fecab1dac to your computer and use it in GitHub Desktop.
Enable Gzip compression in Laravel assets #laravel #php #nginx
In order to enable Gzip compression on your NGINX web server,
first open your NGINX's default configuration file: sudo vim /etc/nginx/nginx.conf,
and replace the existing Gzip settings with the following:
nginx.conf (you can modify the settings below according to your needs)
# Enable Gzip
gzip on;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_min_length 1100;
gzip_buffers 4 8k;
gzip_proxied any;
gzip_types
# text/html is always compressed by HttpGzipModule
text/css
text/javascript
text/xml
text/plain
text/x-component
application/javascript
application/json
application/xml
application/rss+xml
font/truetype
font/opentype
application/vnd.ms-fontobject
image/svg+xml;
gzip_static on;
gzip_proxied expired no-cache no-store private auth;
gzip_disable "MSIE [1-6]\.";
gzip_vary on;
#Restart NGINX
service nginx restart or /etc/init.d/nginx restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment