(nginx) Gzip per request vs static gzip

nginx

Solution

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.

Problem

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?

Original source