I tried to use Drupal's "Optimize CSS Files", which aggregates css and removes whitespace, with boosts css gzip compression, but the gzip does not work.

I used the Firefox web developer extension and saw that the HTML and javascript compress, but not CSS. If I disable Drupal's aggregation, it does compress it properly.

Comments

mikeytown2’s picture

Status: Active » Closed (duplicate)

going to mark this a dup of #543280: serve CSS and JS to logged in users. Please change if this is not the case.

neomenlo’s picture

Status: Closed (duplicate) » Active

Actually it's not the same thing.

I had a problem getting boost to serve compressed CSS when the CSS was aggregated together by Drupal.
This is a bug because the javascript compresses even when it is aggregated by drupal.
It has nothing to do with being logged in or not.

The other bug is an improvement. Boost by design does not serve compressed css/js to logged in users, even though there shouldn't be a problem with it. That is because the rules for serving it are grouped in with the rules for serving static pages, which cannot be served to logged in users.

mikeytown2’s picture

Can you check to see if it is both css files or only one of the aggregated ones. You have the media="all" one and the media="screen" one. Check both dir's gz and normal.

mikeytown2’s picture

Status: Active » Postponed (maintainer needs more info)
chadd’s picture

Version: 6.x-1.0-beta2 » 6.x-1.0-rc2
Status: Postponed (maintainer needs more info) » Active

i'm running into the same (i think) problem.
i have drupal's 'optimize css' enabled, and boost's 'cache css' enabled.

according to YSlow, the non-aggregated css files are never compressed.
in my case, it is 2 theme specific css files (/sites/all/themes/mytheme/assets/style/*) and the views module views.css

it seems that the drupal aggregated .css is being compressed, or at least they aren't showing up as "these should be compressed" in the YSlow report.

i've even tried adding the css gzip module (http://drupal.org/project/css_gzip) to the mix, but that seemed to have no effect.

mikeytown2’s picture

@chadd
Are the css files being stored inside the cache dir?

chadd’s picture

yes, i could find all the files in the cache dir, both normal and gz dirs

mikeytown2’s picture

@chadd
Can you give me one of the file names, full path from webroot and post the boost section of your htaccess file.

chadd’s picture

the files that aren't being compressed (according to YSlow):

WWWRoot/cache/matcmadison.edu/sites/all/modules/views/css/views.css_.css
WWWRoot/cache/matcmadison.edu/sites/all/themes/matc-theme/assets/style/initial.css
WWWRoot/cache/matcmadison.edu/sites/all/themes/matc-theme/assets/style/styleFront.css

and my .htaccess:

 ### BOOST START ###
  <FilesMatch "(\.html\.gz|\.html)$">
    <IfModule mod_headers.c>
      Header set Expires "Sun, 19 Nov 1978 05:00:00 GMT"
      Header set Cache-Control "no-store, no-cache, must-revalidate, post-check=0, pre-check=0"
    </IfModule>
  </FilesMatch>
  <IfModule mod_mime.c>
    AddCharset utf-8 .html
    AddCharset utf-8 .xml
  </IfModule>
  AddEncoding x-gzip .gz
  <FilesMatch "\.html\.gz$">
    ForceType text/html
  </FilesMatch>
  <FilesMatch "\.xml\.gz$">
    ForceType text/xml
  </FilesMatch>
  <FilesMatch "\.css\.gz$">
    ForceType text/css
  </FilesMatch>
  <FilesMatch "\.js\.gz$">
    ForceType text/javascript
  </FilesMatch>

  # Skip boost IF not get request OR uri has wrong dir OR cookie is set OR https request
  RewriteCond %{REQUEST_METHOD} !^GET$ [OR]
  RewriteCond %{REQUEST_URI} (^/(admin|cache|misc|modules|sites|system|themes))|(/(comment/reply|user|user/(login|password|register))$) [OR]
  RewriteCond %{HTTP_COOKIE} DRUPAL_UID [OR]
  RewriteCond %{HTTPS} on
  RewriteRule .* - [S=11]

  # GZIP
  RewriteCond %{HTTP:Accept-encoding} !gzip
  RewriteRule .* - [S=5]

  RewriteCond %{DOCUMENT_ROOT}/cache/gz/%{SERVER_NAME}%{REQUEST_URI}_%{QUERY_STRING}\.html\.gz -s
  RewriteRule .* cache/gz/%{SERVER_NAME}%{REQUEST_URI}_%{QUERY_STRING}\.html\.gz [L,T=text/html]
  RewriteCond %{DOCUMENT_ROOT}/cache/gz/%{SERVER_NAME}%{REQUEST_URI}_%{QUERY_STRING}\.xml\.gz -s
  RewriteRule .* cache/gz/%{SERVER_NAME}%{REQUEST_URI}_%{QUERY_STRING}\.xml\.gz [L,T=text/xml]
  RewriteCond %{DOCUMENT_ROOT}/cache/gz/%{SERVER_NAME}%{REQUEST_URI}_\.css\.gz -s
  RewriteRule .* cache/gz/%{SERVER_NAME}%{REQUEST_URI}_\.css\.gz [L,QSA,T=text/css]
  RewriteCond %{DOCUMENT_ROOT}/cache/gz/%{SERVER_NAME}%{REQUEST_URI}_%{QUERY_STRING}\.js\.gz -s
  RewriteRule .* cache/gz/%{SERVER_NAME}%{REQUEST_URI}_%{QUERY_STRING}\.js\.gz [L,T=text/javascript]
  RewriteCond %{DOCUMENT_ROOT}/cache/gz/%{SERVER_NAME}%{REQUEST_URI}_\.js\.gz -s
  RewriteRule .* cache/gz/%{SERVER_NAME}%{REQUEST_URI}_\.js\.gz [L,QSA,T=text/javascript]

  # NORMAL
  RewriteCond %{DOCUMENT_ROOT}/cache/%{SERVER_NAME}%{REQUEST_URI}_%{QUERY_STRING}\.html -s
  RewriteRule .* cache/%{SERVER_NAME}%{REQUEST_URI}_%{QUERY_STRING}\.html [L,T=text/html]
  RewriteCond %{DOCUMENT_ROOT}/cache/%{SERVER_NAME}%{REQUEST_URI}_%{QUERY_STRING}\.xml -s
  RewriteRule .* cache/%{SERVER_NAME}%{REQUEST_URI}_%{QUERY_STRING}\.xml [L,T=text/xml]
  RewriteCond %{DOCUMENT_ROOT}/cache/%{SERVER_NAME}%{REQUEST_URI}_\.css -s
  RewriteRule .* cache/%{SERVER_NAME}%{REQUEST_URI}_\.css [L,QSA,T=text/css]
  RewriteCond %{DOCUMENT_ROOT}/cache/%{SERVER_NAME}%{REQUEST_URI}_%{QUERY_STRING}\.js -s
  RewriteRule .* cache/%{SERVER_NAME}%{REQUEST_URI}_%{QUERY_STRING}\.js [L,T=text/javascript]
  RewriteCond %{DOCUMENT_ROOT}/cache/%{SERVER_NAME}%{REQUEST_URI}_\.js -s
  RewriteRule .* cache/%{SERVER_NAME}%{REQUEST_URI}_\.js [L,QSA,T=text/javascript]
  ### BOOST END ###
mikeytown2’s picture

Version: 6.x-1.0-rc2 » 6.x-1.x-dev
Status: Active » Needs review
StatusFileSize
new5.29 KB

Try this, it's for the latest dev; it also has some of the beginning of this thread: #546850: Next round of .htaccess changes. Getting these "perfect" is the goal..

The important part of this is the stuff inside the for loop and the code above it.

mikeytown2’s picture

StatusFileSize
new5.41 KB

Here's a better one

mikeytown2’s picture

Status: Needs review » Fixed

committed

chadd’s picture

Status: Fixed » Active

i just updated to the latest dev 6.x-1.x-dev (2009-Aug-31) and added the boosted1.txt from that release to my .htaccess and the problem seems to still be there...
in fact, now YSlow is reporting that the aggregated css is not being compressed either.

the files are still all being created (both gz and normal) just not being served (at least according to YSlow...)

mikeytown2’s picture

grab the htaccess rules from the performace/boost page, as these are generated to fit your setup. Let me know if that does it for you.

mikeytown2’s picture

Status: Active » Needs review
StatusFileSize
new5.97 KB

changes to the htaccess1/2.txt files

mikeytown2’s picture

Status: Needs review » Fixed

committed, please change back to active if it still doesn't work.

chadd’s picture

Version: 6.x-1.x-dev » 6.x-1.0-rc3
Status: Fixed » Active

Now it looks like none of the css is being served via gz, and it also looks like now the page itself isn't being served via gz.
it's all there in the gz dir, but not being served (according to yslow)

Boost 6.x-1.0-rc3 using the .htaccess from rules from the performace/boost page

mikeytown2’s picture

@chadd
Any chance I could get a login to look around your site to try and see what is wrong? use my contact form.
http://drupal.org/user/282446/contact

mikeytown2’s picture

Your server is not serving any gzip content other then the jsmin.js.gz file from the http://drupal.org/project/javascript_aggregator module. For some reason it's completely ignoring the gzip part of the boost rules. Luckily RC3 has the fix, I just tested it on your server! Enable 'Do an iframe javascript cookie test for gzip' on the performance/boost page. I tested this by setting the boost-gzip cookie. As for why javascript_aggregator is working and boost isn't, is very strange since I helped get gzip working on that module. It might have to do with firewall issues; here's the article that inspired me to add this functionality.
http://actionable-stats.com/website-performance-activate-gzip

Just for kicks can I see your root htaccess file and the one located in files/js/

chadd’s picture

the odd thing is that our production server, running Boost 6.x-1.0-rc2, serves up all gz files without a problem except for the non-aggregated css mentioned above. or at least, the only files that YSlow complains about not being gz is the non aggregated css...

after enabling the 'iframe' check it looks like all the files get served via gz in the RC3.
does the iframe cookie test have any impact on load times or browser compatibility?

here's the files you requested:

root .htaccess

AuthUserFile "/Web/dev/.htpasswd"
AuthName "Restricted Access"
AuthType Basic
Require valid-user


#
# Apache/PHP/Drupal settings:
#

# Protect files and directories from prying eyes.
<FilesMatch "\.(engine|inc|info|install|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl|svn-base)$|^(code-style\.pl|Entries.*|Repository|Root|Tag|Template|all-wcprops|entries|format)$">
  Order allow,deny
</FilesMatch>

# Don't show directory listings for URLs which map to a directory.
Options -Indexes

# Follow symbolic links in this directory.
Options +FollowSymLinks

# Make Drupal handle any 404 errors.
ErrorDocument 404 /index.php

# Force simple error message for requests for non-existent favicon.ico.
<Files favicon.ico>
  # There is no end quote below, for compatibility with Apache 1.3.
  ErrorDocument 404 "The requested file favicon.ico was not found.
</Files>

# Set the default handler.
DirectoryIndex index.php

# Override PHP settings. More in sites/default/settings.php
# but the following cannot be changed at runtime.

# PHP 4, Apache 1.
<IfModule mod_php4.c>
  php_value magic_quotes_gpc                0
  php_value register_globals                0
  php_value session.auto_start              0
  php_value mbstring.http_input             pass
  php_value mbstring.http_output            pass
  php_value mbstring.encoding_translation   0
</IfModule>

# PHP 4, Apache 2.
<IfModule sapi_apache2.c>
  php_value magic_quotes_gpc                0
  php_value register_globals                0
  php_value session.auto_start              0
  php_value mbstring.http_input             pass
  php_value mbstring.http_output            pass
  php_value mbstring.encoding_translation   0
</IfModule>

# PHP 5, Apache 1 and 2.
<IfModule mod_php5.c>
  php_value magic_quotes_gpc                0
  php_value register_globals                0
  php_value session.auto_start              0
  php_value mbstring.http_input             pass
  php_value mbstring.http_output            pass
  php_value mbstring.encoding_translation   0
</IfModule>

# Requires mod_expires to be enabled.
<IfModule mod_expires.c>
  # Enable expirations.
  ExpiresActive On

  # Cache all files for 2 weeks after access (A).
  ExpiresDefault A1209600

  # Do not cache dynamically generated pages.
  ExpiresByType text/html A1
</IfModule>

# Various rewrite rules.
<IfModule mod_rewrite.c>
  RewriteEngine on

  # If your site can be accessed both with and without the 'www.' prefix, you
  # can use one of the following settings to redirect users to your preferred
  # URL, either WITH or WITHOUT the 'www.' prefix. Choose ONLY one option:
  #
  # To redirect all users to access the site WITH the 'www.' prefix,
  # (http://example.com/... will be redirected to http://www.example.com/...)
  # adapt and uncomment the following:
  # RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
  # RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
  #
  # To redirect all users to access the site WITHOUT the 'www.' prefix,
  # (http://www.example.com/... will be redirected to http://example.com/...)
  # uncomment and adapt the following:
  # RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
  # RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]

  # Modify the RewriteBase if you are using Drupal in a subdirectory or in a
  # VirtualDocumentRoot and the rewrite rules are not working properly.
  # For example if your site is at http://example.com/drupal uncomment and
  # modify the following line:
  # RewriteBase /drupal
  #
  # If your site is running in a VirtualDocumentRoot at http://example.com/,
  # uncomment the following line:
  # RewriteBase /
  ### BOOST START ###
  <FilesMatch "(\.html\.gz|\.html|\.xml\.gz|\.xml|\.js\.gz|\.js)$">
    <IfModule mod_headers.c>
      Header set Expires "Sun, 19 Nov 1978 05:00:00 GMT"
      Header set Cache-Control "no-store, no-cache, must-revalidate, post-check=0, pre-check=0"
    </IfModule>
  </FilesMatch>
  <IfModule mod_mime.c>
    AddCharset utf-8 .html
    AddCharset utf-8 .xml
    AddCharset utf-8 .css
    AddCharset utf-8 .js
    AddCharset utf-8 .js
    AddEncoding gzip .gz
  </IfModule>
  <FilesMatch "\.html\.gz$">
    ForceType text/html
  </FilesMatch>
  <FilesMatch "\.xml\.gz$">
    ForceType text/xml
  </FilesMatch>
  <FilesMatch "\.css\.gz$">
    ForceType text/css
  </FilesMatch>
  <FilesMatch "\.js\.gz$">
    ForceType text/javascript
  </FilesMatch>
  <FilesMatch "\.js\.gz$">
    ForceType text/javascript
  </FilesMatch>

  # Gzip Cookie Test
  RewriteRule boost-gzip-cookie-test\.html  cache/gz/boost-gzip-cookie-test\.html\.gz [L,T=text/html]

  # GZIP - Cached css & js files
  RewriteCond %{HTTP_COOKIE} !(boost-gzip) [OR]
  RewriteCond %{HTTP:Accept-encoding} !gzip
  RewriteRule .* - [S=2]
  RewriteCond %{DOCUMENT_ROOT}/cache/gz/%{SERVER_NAME}%{REQUEST_URI}_\.css\.gz -s
  RewriteRule .* cache/gz/%{SERVER_NAME}%{REQUEST_URI}_\.css\.gz [L,QSA,T=text/css]
  RewriteCond %{DOCUMENT_ROOT}/cache/gz/%{SERVER_NAME}%{REQUEST_URI}_\.js\.gz -s
  RewriteRule .* cache/gz/%{SERVER_NAME}%{REQUEST_URI}_\.js\.gz [L,QSA,T=text/javascript]

  # NORMAL - Cached css & js files
  RewriteCond %{DOCUMENT_ROOT}/cache/%{SERVER_NAME}%{REQUEST_URI}_\.css -s
  RewriteRule .* cache/%{SERVER_NAME}%{REQUEST_URI}_\.css [L,QSA,T=text/css]
  RewriteCond %{DOCUMENT_ROOT}/cache/%{SERVER_NAME}%{REQUEST_URI}_\.js -s
  RewriteRule .* cache/%{SERVER_NAME}%{REQUEST_URI}_\.js [L,QSA,T=text/javascript]

  # Caching for anonymous users
  # Skip boost IF not get request OR uri has wrong dir OR cookie is set OR https request
  RewriteCond %{REQUEST_METHOD} !^GET$ [OR]
  RewriteCond %{REQUEST_URI} (^(admin|cache|misc|modules|sites|system|themes|node/add))|(/(comment/reply|edit|user|user/(login|password|register))$) [OR]
  RewriteCond %{HTTP_COOKIE} DRUPAL_UID [OR]
  RewriteCond %{HTTPS} on
  RewriteRule .* - [S=7]

  # GZIP
  RewriteCond %{HTTP_COOKIE} !(boost-gzip) [OR]
  RewriteCond %{HTTP:Accept-encoding} !gzip
  RewriteRule .* - [S=3]
  RewriteCond %{DOCUMENT_ROOT}/cache/gz/%{SERVER_NAME}%{REQUEST_URI}_%{QUERY_STRING}\.html\.gz -s
  RewriteRule .* cache/gz/%{SERVER_NAME}%{REQUEST_URI}_%{QUERY_STRING}\.html\.gz [L,T=text/html]
  RewriteCond %{DOCUMENT_ROOT}/cache/gz/%{SERVER_NAME}%{REQUEST_URI}_%{QUERY_STRING}\.xml\.gz -s
  RewriteRule .* cache/gz/%{SERVER_NAME}%{REQUEST_URI}_%{QUERY_STRING}\.xml\.gz [L,T=text/xml]
  RewriteCond %{DOCUMENT_ROOT}/cache/gz/%{SERVER_NAME}%{REQUEST_URI}_%{QUERY_STRING}\.js\.gz -s
  RewriteRule .* cache/gz/%{SERVER_NAME}%{REQUEST_URI}_%{QUERY_STRING}\.js\.gz [L,T=text/javascript]

  # NORMAL
  RewriteCond %{DOCUMENT_ROOT}/cache/%{SERVER_NAME}%{REQUEST_URI}_%{QUERY_STRING}\.html -s
  RewriteRule .* cache/%{SERVER_NAME}%{REQUEST_URI}_%{QUERY_STRING}\.html [L,T=text/html]
  RewriteCond %{DOCUMENT_ROOT}/cache/%{SERVER_NAME}%{REQUEST_URI}_%{QUERY_STRING}\.xml -s
  RewriteRule .* cache/%{SERVER_NAME}%{REQUEST_URI}_%{QUERY_STRING}\.xml [L,T=text/xml]
  RewriteCond %{DOCUMENT_ROOT}/cache/%{SERVER_NAME}%{REQUEST_URI}_%{QUERY_STRING}\.js -s
  RewriteRule .* cache/%{SERVER_NAME}%{REQUEST_URI}_%{QUERY_STRING}\.js [L,T=text/javascript]

  ### BOOST END ###




  # Rewrite URLs of the form 'x' to the form 'index.php?q=x'.
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !=/favicon.ico
  RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
  

  
</IfModule>

# $Id: .htaccess,v 1.90.2.3 2008/12/10 20:04:08 goba Exp $

files/js/.htaccess

<Files *.js.gz>
AddEncoding x-gzip .gz
ForceType text/javascript
</Files>
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} !".*Safari.*"
RewriteCond %{HTTP:Accept-encoding} gzip
RewriteCond %{REQUEST_FILENAME}.gz -f
RewriteRule ^(.*)\.js $1.js.gz [L,QSA]
</IfModule>
mikeytown2’s picture

The 'iframe' check is only injected on the front page, and only on the non-gzip version of that; and it uses a static html file to check, so the performance impact is minimal. It shouldn't effect browser compatibility, as browsers that don't understand gzip can't read the iframe, thus can't get a cookie set. If you have a blackberry then you can test this on a non gzip supported browser. Also means that if the user doesn't hit the front page then, they won't get that cookie set. It's set to last for 2 weeks.

What this output?

echo $_SERVER['HTTP_ACCEPT_ENCODING'];

The only thing I can think of is the not (!)

RewriteCond %{HTTP:Accept-encoding} !gzip
RewriteCond %{HTTP:Accept-encoding} gzip
chadd’s picture

upgrading to RC3(4) worked and now everything is being served via gz.

thanks much!
this module is a lifesaver.

mikeytown2’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.