Hi

I'm having problems getting CSS Gzip to work.

It does generate the .gz compressed version of the CSS file in /sites/default/files/css
It does generate a .htaccess file en the same folder, if so chosen.
I tried the "do not generate .htaccess" option, and manually modified the root .htaccess
I do have clean url's and public download method.
I flushed cache, logged out, ran cron, refreshed page, reinstalled, several times.

Yet YSlow still reports that the regular uncompressed .css file is served.

Any ideas what I have missed?

My drupal site is located at oldrup dot dk
PHP info is http://web5.gigahost.dk/phpinfo.php

Best regards
Bjarne

CommentFileSizeAuthor
#20 gzip_css.jpg60.66 KBwadmiraal
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mikeytown2’s picture

Can I get a URL to an example site where it doesn't work?

sittard’s picture

Check the file size of your .htaccess and the permission in /sites/default/files/css

I had a strange file permission issue which meant the the file existed but it was empty. To recreate it you need to delete the file and save the configuration in the performance option.

netbjarne’s picture

Hi!

Thankyou both for feedback, and sorry for not replying until now, I must check my email notification settings ;)

URL: oldrup.dk

Contents of .htaccess in /sites/default/files/css looks alright to me, and deletes and creates just fine:

# 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>

Please let me know if I can give further info to solve this puzzle. My YSlow and Google Pagespeed ranks are getting very good, CSS compression is the only thing lacking :)

netbjarne’s picture

A few days ago, i updated the acquia slate theme to version 2.0, that didn't change anything. Next I will try with a testsite, using only a fresh install of drupal core and css gzip.

Oh, and another thing. I'm having the excact same problem with Javascript aggregator http://drupal.org/project/javascript_aggregator - the module creates the gz file, but it is not server - it does minify the javascripts, and that works.

Kind regards
Bjarne

KoCo’s picture

I use the acquia marina theme and have to use the hook exit option.

AgaPe’s picture

Have the same with javascript and css modules.. Tried different settings on Performance page.

betancourt’s picture

I got the same issue on a shared server and the support team told me the gzip is turned on and off depending on the server load? why is this? any ideas or further clarification? Thanks

bflora’s picture

Am having the same problem. Module is installed and creating gzipped css files and a new .htaccess in files/css, but the actual gzipped css is not being substituted for the compressed .css file so I'm still serving up the un-gzipped file to my visitors.

Is the htaccess file the one that's supposed to cause the substitution to happen?

My files/css folder is set to 777 btw.

Url for this site: http://windycitizen.com

Will happily pay for 30 minutes of the maintainer's time to troubleshoot this. Contact info is in my profile. Cheers!

mikeytown2’s picture

@bflora
your server is nginx & i get Content-Encoding: gzip when downloading a css file from your server. nginx is a lot more efficient in comparison to apache; doing gzip at the server level should be fine in your case. If you still want to use *.gz files then this should work
http://wiki.nginx.org/HttpGzipStaticModule

bflora’s picture

Anonymous visitors get nginx (which is fast). Logged in users get apache (which can be slow). So gzipping still has value.

mikeytown2’s picture

try the alt where you place the htaccess rules inside your webroot .htaccess file (same level as index.php)
Directions are in the readme
http://drupalcode.org/viewvc/drupal/contributions/modules/css_gzip/READM...

bflora’s picture

The documentation is a bit confusing:

It says to "Add this Inside the block, right before (add it to the bottom)"

But then the code snippet actually includes and tags. So do I put that code inside of my existing set of and or do I take the code inside those and tags and put it inside my existing ones.

And what about the handful of lines above the and tags? Do I put those into the .htaccess file above my existing and tags in my Drupal htaccess?

I already have a Drupal htaccess with and tags and lots of rewrite rules. Unclear how to proceed based on the instructions in the readme.

bflora’s picture

Also, then after I make whatever changes need to be made. Do I need to restart apache? Clear my cache?

momper’s picture

subscribe

SocialNicheGuru’s picture

I am having the exact same issue.

css.gz is being created in files/css but it is not being served
I am on apache2
clean urls
public download
css file permission 770

I used the regular setting and chose not to modify my .htaccess file.
I am having the same issue with javascript_aggregator also

Test 1: mod_deflate enabled
cleared all caches
results as above

Test 2: mod_deflate disabled
cleared all caches
results as above

I do have mod_deflate enabled and have to for another server that I have running
I would like to use css_gzip for the drupal related content

any help would be greatly appreciated.

armanschwarz’s picture

I am also experiencing this: CSS being GZipped but not served. My Javascript isn't being served as GZipped either though so this can't be CSS GZip's fault. Any ideas? I'm on a shared host, and not getting any errors...

kirtimansharma’s picture

subscribe

Rob C’s picture

subscribe

suryav’s picture

Priority: Normal » Major

Any luck on this issue yet? I tried all possibilities (modifying root .htacees, disabling the auto-generated .htaccess, etc.) I am having the same exact issue - I see all the .css.gz and .js.gz files under /sites/default/files/css/ and /sites/default/files/js/ but viewsource still shows the .css and .js files served up.

This seems to be fixed in D7, can someone port the fixes for D6 and post a patch here?

wadmiraal’s picture

FileSize
60.66 KB

For everyone: have you checked the Content-Encoding header you get with your CSS file ? As far as I know, the .htaccess rule rewrites the URL. So the URL in your HTML will be *.css, but Apache should serve the *css.gz file.

If you use Firefox, install Firebug and check the content encoding (see screenshot). In the screenshot, you'll see that the file extension is *.css, but the encoding is gzip. In our case, the module is working.

Hope this will help some of you.

DonnyCarette’s picture

Same issues (Module does work on some hosts)
.HTACCESS and gzipt CSS files are generated but the headers are not send correctly which has as result that the site is displayed without CSS.

+++ UPDATE +++
Issue seems to be on LiteSpeed server.
On the performance configuration page set CSS Gzip and Gzip Javascript to not generate a .htaccess file
Place the following code inside your root .htaccess (Make sure that there aren't any .htaccess files inside the css en js folders anymore)
(Paste code inside )

  # 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 "(\.css\.gz)$">
    # Serve correct encoding type.
    Header append Content-Encoding gzip
    # Force proxies to cache gzipped & non-gzipped css/js files separately.
    Header append Vary Accept-Encoding
  </FilesMatch>
  <FilesMatch "(\.js\.gz)$">
    Header set Content-Type text/javascript
    Header append Content-Encoding gzip
    Header append Vary Accept-Encoding
  </FilesMatch>
eg208’s picture

Hi
#21 Work for me, thanks

mikeytown2’s picture

Status: Active » 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.