Problem with mod_deflate

I have the following code in my .htaccess files:

<FilesMatch "\\.(js|css|html)$">
SetOutputFilter DEFLATE
</FilesMatch>

On some sites, it works as expected, but on other sites the compression is applied to all files, including images. Where am I going wrong?

I have looked through the forums and found Mittineague’s recommendation of

<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/xml text/css text/plain
AddOutputFilterByType DEFLATE img/svg+xml application/xhtml+xml application/xml
AddOutputFilterByType DEFLATE application/rdf+xml application/rss+xml application/atom+xml
AddOutputFilterByType DEFLATE text/javascript application/javascript application/x-javascript
AddOutputFilterByType DEFLATE application/x-font-ttf application/x-font-otf
AddOutputFilterByType DEFLATE font/truetype font/opentype
</IfModule>

Is this a better approach? (And should I remove the <IfModule> tags to avoid upsetting dklynn? :slight_smile: )