How to not compress or exclude images from gzip compression in htaccess

Hi

I’ve been doing some page test and get this “You should not gzip/deflate PNG images” I didn’t know gzip compression also included images.

The only thing I have concerning compression in my htaccess is:

	##### serve pre gziped files #####
    # Rules to correctly serve gzip compressed CSS and JS files.
    # Requires both mod_rewrite and mod_headers to be enabled.
    # Serve gzip compressed CSS files if they exist and the client accepts gzip.
    RewriteCond %{HTTP:Accept-encoding} gzip
    RewriteCond %{REQUEST_FILENAME}\.gz -s
    RewriteRule ^(.*)\.css $1\.css\.gz [L,QSA]

    # Serve gzip compressed JS files if they exist and the client accepts gzip.
    RewriteCond %{HTTP:Accept-encoding} gzip
    RewriteCond %{REQUEST_FILENAME}\.gz -s
    RewriteRule ^(.*)\.sj $1\.js\.gz [L,QSA]

    # Serve correct content types, and prevent mod_deflate double gzip.
    RewriteRule \.css\.gz$ - [T=text/css,E=no-gzip:1]
    RewriteRule \.js\.gz$ - [T=text/javascript,E=no-gzip:1]



   <FilesMatch "(\.js\.gz|\.css\.gz)$">
    # Serve correct encoding type.
    Header append Content-Encoding gzip
    # Force proxies to cache gzipped & non-gzipped css/js files separately.
    Header append Vary Accept-Encoding
   </FilesMatch>

How can I exclude images?

Than you

This .htaccess does not affect .png images at all. It must be somewhere else in the server configuration.
Do you have access to the main server config or are you on shared hosting?

Yes you are correct. I found the problem in the Apache configuration.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.