If you configure and install nginx with the flag --with-http_gzip_static_module
and then you turn on the static gzipping gzip_static on;
.
HttpGzipStaticModule
With static gzip when nginx receives a file request it tries to read and return the same file with an extension ".gz".
My quesion is: This seems to be a better choice than gzipping the file when the user does the request because the file is already gzipped, right? You win speed, you can serve the files faster. Right now I have gzipped font files and I send to the user a bundle with all the js (concatenated, minified and gzipped) an another bundle with all the css. Should I also pre-gzip the images?
Yes, using HttpGzipStaticModule is better (when possible), for 2 reasons:
gzip --fastest
by default), which means:
Note that both the lesser load and the lesser bandwidth use will lower your datacenter bills (though that's only really noticable for big, busy sites)
Since that part of the question wasn't answered:
Don't gzip images. JPEG and PNG files are already compressed and re-compressing them with gzip may have little effect, and it may in fact result in larger file sizes. By default, nginx doesn't compress image files using its per-request gzip module.
If you want to reduce the size of your images, you may wanna look into the webp file format or the pagespeed module that can handle optimising images for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With