Let’s see Enabling Gzip compression and browser caching with Nginx on Plesk with the support of our Plesk hosting support services at Bobcares.
Enabling gzip compression for a domain in Plesk
To enable the gzip compression for a domain in plesk follow the steps given below:
- Connect to Plesk.
- Navigate to Domains – example.com. Then navigate to the Apache & nginx Settings.
- Fill in the Additional nginx directives field with the following directives:
- Finally, apply the changes to finish the enabling gzip compression for a domain in Plesk.
Disable gzip compression for a domain in Plesk
To disable the Gzip compression follow the steps given below:
- Connect to Plesk.
- Navigate to Domains > example.com > Apache & nginx Configuration.
- To stop gzip compression for a domain/subdomain that does not exist in Plesk (for example, hostname), first create it.
- To the Additional nginx directives field, add the following directive:
gzip disable;
- To save the changes, click Apply this will disable Gzip compression and browser caching with Nginx on Plesk
How to enable gzip compression server-wide?
To set this up follow the steps given below:
- Use SSH to connect to a Plesk server.
- Make the following changes to the gzip.conf file in the nginx conf.d directory:
# touch /etc/nginx/conf.d/gzip.conf
- After that, we have to open any text editor. Note that in the example given below we are using the Vi editor:
# vi /etc/nginx/conf.d/gzip.conf
- Fill it with the following content:
gzip on;
gzip_disable "MSIE [1-6].(?!.*SV1)";
gzip_proxied any;
gzip_comp_level 5;
gzip_types text/plain text/css application/javascript application/x-javascript text/xml application/xml application/rss+xml text/javascript image/x-icon image/bmp image/svg+xml;
gzip_vary on; - Save the modifications and exit the file and continue enabling Gzip compression and browser caching with Nginx on Plesk.
- Nginx setup test:
# nginx -t
- To implement the changes, reload the nginx configuration:
# service nginx reload
- All domains on the server now have gzip compression enabled.
Use the command below to see if gzip compression is enabled.
When gzip is enabled, the output will show ‘Content-Encoding: gzip’:
a: If the webpage is accessible through HTTP:
# curl -s -H “Accept-Encoding: gzip” -I http://example.com | grep -i Content-Encoding
Content-Encoding: gzipb: If the website employs an HTTPS connection:
# curl -s -H “Accept-Encoding: gzip” -I https://example.com –insecure | grep -i Content-Encoding
Content-Encoding: gzip
How to Disable gzip compression server-wide?
After Enabling Gzip compression and browser caching with Nginx on Plesk we have to option to disbale it server-wide.
Follow the steps given below to disable this:
- Connect to a server using…
- SSH is used to connect to a server.
- Search all nginx configuration files for the line “gzip on”:
grep -Ri "gzip on" /etc/nginx/
- To turn off gzip compression, open the file in a text editor and change gzip on to gzip off.
- Save the modifications and exit the file.
- Finally to make the modifications take effect, restart nginx:
service nginx restart
[Need assistance with similar queries? We are here to help]
Conclusion
To sum up we have now seen more on Enabling Gzip compression and browser caching with Nginx on Plesk with the support of our tech support team.
PREVENT YOUR SERVER FROM CRASHING!
Never again lose customers to poor server speed! Let us help you.
Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.
0 Comments