I got a recommendation to add Gzip to my site (for better page loading and thus better SEO). How can one apply that to Drupal? Thanks very much indeed !

Comments

That is a function of your web server and will depend on where/how the site is hosted.

Yes, it has nothing to do with Drupal, as it is done at the server level.

Jaypan
Our newest Drupal site: PacificAikido.com (Drupal showcase)

If you've mod_deflate enabled you can test the following to drupal's .htaccess

# enable mod_deflate for compression of text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

if mod_gzip you can test the following to drupal's .htaccess

<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
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.*
</ifModule>

This will send compressed content regardless of browser headers, I'm guessing ?

// Ayesh

I can't explain the technical aspects. testing mod_deflate on my own site did increase page loading times.

This will send compressed content regardless of browser headers, I'm guessing ?

// Ayesh

You can use this tool to see if gzip compression is working on your site:

http://www.whatsmyip.org/http-compression-test/

www.tmdhosting.com
---------------------
Drupal Hosting, Free Drupal Installations, Free Module and Theme Installations, Free Upgrades, Free Drupal

reading the core .htaccess files I'm not sure why the addition helps. Core's already existing rules are:

# Rules to correctly serve gzip compressed CSS and JS files.
  # Requires both mod_rewrite and mod_headers to be enabled.
  <IfModule mod_headers.c>
    # 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 [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 ^(.*)\.js $1\.js\.gz [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 set Content-Encoding gzip
      # Force proxies to cache gzipped & non-gzipped css/js files separately.
      Header append Vary Accept-Encoding
    </FilesMatch>
  </IfModule>
</IfModule>