24 March 2019

List of mimetypes to compress. You should not compress mime types that compress badly. Compressing images would not result in a lot of gain, but will use a lot of cpu. You can copy this snippet to .htaccess. This only work when you have mod_deflate enabled in Apache. You can use this code in Apache configuration to make this work globally.

Source code viewer
  1. # Deflate.
  2. <IfModule mod_deflate.c>
  3. # Compress HTML, CSS, JavaScript, Text, XML and fonts
  4. AddOutputFilterByType DEFLATE application/javascript
  5. AddOutputFilterByType DEFLATE application/rss+xml
  6. AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
  7. AddOutputFilterByType DEFLATE application/x-font
  8. AddOutputFilterByType DEFLATE application/x-font-opentype
  9. AddOutputFilterByType DEFLATE application/x-font-otf
  10. AddOutputFilterByType DEFLATE application/x-font-truetype
  11. AddOutputFilterByType DEFLATE application/x-font-ttf
  12. AddOutputFilterByType DEFLATE application/x-javascript
  13. AddOutputFilterByType DEFLATE application/xhtml+xml
  14. AddOutputFilterByType DEFLATE application/xml
  15. AddOutputFilterByType DEFLATE font/opentype
  16. AddOutputFilterByType DEFLATE font/otf
  17. AddOutputFilterByType DEFLATE font/ttf
  18. AddOutputFilterByType DEFLATE image/svg+xml
  19. AddOutputFilterByType DEFLATE image/x-icon
  20. AddOutputFilterByType DEFLATE text/css
  21. AddOutputFilterByType DEFLATE text/html
  22. AddOutputFilterByType DEFLATE text/javascript
  23. AddOutputFilterByType DEFLATE text/plain
  24. AddOutputFilterByType DEFLATE text/xml
  25.  
  26. # Remove browser bugs (only needed for really old browsers)
  27. BrowserMatch ^Mozilla/4 gzip-only-text/html
  28. BrowserMatch ^Mozilla/4\.0[678] no-gzip
  29. BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
  30. Header append Vary User-Agent
  31. </IfModule>
Programming Language: Apache configuration