How to send compressed (deflated) SVG via Apache2?
If Apache doesn't know the mime type of the file (here image/svg+xml), you need to tell it specifically (not needed in most Apaches):
AddType image/svg+xml svg svgz
Now when Apache knows about the filetype, just add this to deflate it:
AddOutputFilterByType DEFLATE image/svg+xml
For more information see https://httpd.apache.org/docs/2.4/mod/mod_deflate.html
I suspect this is due to the plus sign in the MIME type, which may need escaping in the AddOutputFilterByType directive. You can also try using the AddOutputFilter directive instead, to process all files with a certain extension:
AddOutputFilter DEFLATE svg
Best option I found is to compress everything except images, which mod_deflate isn't able to handle it.
add following lines to httpd.conf
file:
LoadModule deflate_module modules/mod_deflate.soSetOutputFilter DEFLATEBrowserMatch ^Mozilla/4 gzip-only-text/htmlBrowserMatch ^Mozilla/4\.0[678] no-gzipBrowserMatch \bMSIE !no-gzip !gzip-only-text/htmlSetEnvIfNoCase Request_URI \\.(?:gif|jpe?g|png|exe)$ no-gzip dont-vary
If u want to see logging of what was compressed add the following also:
DeflateFilterNote Input instreamDeflateFilterNote Output outstreamDeflateFilterNote Ratio ratioLogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflateCustomLog logs/deflate_log deflate