GZIP Compression for all HTML elements

'm trying to GZIP compression in .htaccess file, I have tested the HTML pages and they are all being compressed for some reason it won't compress my javascripts and css files?

Does anyone know the code to add in the htaccess file to ensure all elements are compressed in the website?

asked May 13, 2015 in htaccess by rajesh
0 votes

1 Answer

0 votes

Are you sure you're also including js and css file extensions?

  mod_gzip_on Yes
  mod_gzip_dechunk Yes
  # filetypes to cover
  mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
  mod_gzip_item_include handler ^cgi-script$
  mod_gzip_item_include mime ^text/.*
  mod_gzip_item_include mime ^application/x-javascript.*
  mod_gzip_item_exclude mime ^image/.*
  mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*



    #The following line is enough for .js and .css
    AddOutputFilter DEFLATE js css
    AddOutputFilterByType DEFLATE text/plain text/xml application/xhtml+xml text/css application/xml application/rss+xml application/atom_xml application/x-javascript application/x-httpd-php application/x-httpd-fastphp text/html     
    #The following lines are to avoid bugs with some browsers
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    BrowserMatch ^Mozilla/4\.0[678] no-gzip
    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html 
answered May 13, 2015 by rajesh