/go/gzip: gzip from the Command Line

gzip makes the web server compress the pages it sends, which saves bandwidth and makes sites load faster. /go/gzip shows or changes the gzip setting in /etc/nginx/nginx.conf and then reloads the web server with reload. The command works on Nginx only. Apache servers use their own compression module (mod_deflate), which this command doesn't change. Every admin action in GoAdmio has a matching /go/ command, so anything you can click you can also script.

Quick start

# Show the current setting
/go/gzip return

# Turn compression on
/go/gzip on

Options

Argument Effect
(none) Asks for a value. The current value is filled in, so press Enter to keep it.
on Sets gzip on;.
off Sets gzip off;.
default Sets gzip on;. Note that this is GoAdmio’s default, not Nginx’s own default, which is off.
return Prints the current value and exits without changing anything.

[!WARNING]
Any other value is written to the file as it is. Nginx accepts only on and off for gzip, so anything else makes the configuration invalid and the reload fails.

Examples

# Show the current setting
/go/gzip return

# Turn compression on
/go/gzip on

# Use GoAdmio's default (on)
/go/gzip default

# Turn compression off, for example when a CDN already compresses the pages
/go/gzip off

# Change it interactively
/go/gzip

# Check that pages are compressed
curl -sI -H "Accept-Encoding: gzip" https://example.com | grep -i content-encoding

Output

With return, the command prints the current value:

on

When it changes the setting, the output comes from the reload command that runs afterwards.

Outcome What you get
Value changed The setting is rewritten and the web server is reloaded.
return The current value.
No gzip line in nginx.conf gzip not exists. Exit status 1.

See the full reference at /go/gzip and the GoAdmio command index.

GoAdmio is free and open source, with no license fees and no account limits. Read the GoAdmio docs, or see why it is a free cPanel alternative at goadmio.com.

By:

Posted in:


Leave a Reply

Your email address will not be published. Required fields are marked *