I noticed the other discussions about mod_deflate vs css_gzip.
I would like to use the caching of css_gzip, but still would like to use mod_deflate for other content.

So, is there any way I can tell mod_deflate to not gzip css.gz and js.gz files (because they are already gzipped)?
Or, is there any way that Apache could gzip and cache my css files?

Ideally with a .htaccess setting.

I am also a bit confused by the
"Certain hosts do not like multiple .htaccess files. To get around this issue ..."
statement.

The statement suggests that css_gzip attempts to create a new .htaccess file somewhere. If it does so, I would like to know more about that!

Thanks!

CommentFileSizeAuthor
#6 css_gzip-713880.patch760 bytesmikeytown2
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mikeytown2’s picture

It creates a .htaccess file in the sites/default/files/css directory. It uses the same technique as Javascript Aggregator; that creates one in the sites/default/files/js directory. So in these generated .htaccess files you could then turn off apache's mod_deflate and be ready to go.

donquixote’s picture

Nice, but how would this modified .htaccess look like?
Sorry, my htaccess fu is not the best (and maybe other readers will feel the same).

mikeytown2’s picture

what does your mod_deflate rules look like?

donquixote’s picture

Looking into /etc/apache2/mods-enabled/deflate.conf.
I'm talking about two different servers, which host totally different sites.

Server I:

<IfModule mod_deflate.c>
  AddOutputFilterByType DEFLATE text/html text/plain text/xml  text/css  application/javascript
</IfModule>

Server II:

<IfModule mod_deflate.c>
  AddOutputFilterByType DEFLATE text/html text/plain text/xml
</IfModule>

Auto-generated .htaccess file in sites/default/files/css (Server II):

# Requires mod_mime to be enabled.
<IfModule mod_mime.c>
  # Send any files ending in .gz with x-gzip encoding in the header.
  AddEncoding gzip .gz
</IfModule>
# Gzip compressed css files are of the type 'text/css'.
<FilesMatch "\.css\.gz$">
  ForceType text/css
</FilesMatch>
<IfModule mod_rewrite.c>
  RewriteEngine on
  # Serve gzip compressed css files
  RewriteCond %{HTTP:Accept-encoding} gzip
  RewriteCond %{REQUEST_FILENAME}\.gz -s
  RewriteRule ^(.*)\.css $1\.css\.gz [L,QSA,T=text/css]
</IfModule>

deflate.load (Server I and II)

LoadModule deflate_module /usr/lib/apache2/modules/mod_deflate.so
mikeytown2’s picture

Looking to the apache documentation there isn't any explanation on how to "turn off" deflate for certain directories/.htaccess-files, but you can try this.
http://httpd.apache.org/docs/trunk/mod/mod_deflate.html
http://httpd.apache.org/docs/trunk/mod/mod_setenvif.html

Place this at the top of the Auto-generated .htaccess file

  SetEnvIfNoCase Request_URI "\.css$" no-gzip dont-vary
mikeytown2’s picture

Status: Active » Needs review
FileSize
760 bytes
pwaterz’s picture

check out his tutorial from how to forge http://www.howtoforge.com/apache2_mod_deflate

mikeytown2’s picture

Status: Needs review » Closed (won't fix)

CSS Gzip will no longer be updated/supported. All future development is being done in the Advanced CSS/JS Aggregation module.