2

Under performance settings in my D7 site, I have "Aggregate and compress CSS files" enabled.

When I run YSlow, I get this:

Grade F on Compress components with gzip. There are 4 plain text components that should be sent compressed:

  • /files/css/css_CKoWqiBj9gVXhPuDSnNphuEB0b0J2To76x0pX0EGqn4.css
  • /files/css/css_5lmdLBQE3741385dmh2zZ_gO_fPyq-62r9KkuUzfIH0.css
  • /files/css/css_UIg6lj2uEi5H1zubqecd1x6N7_ejFWRiwKYJ_qrEmOQ.css
  • /files/css/css_oYatxLY13v2flmA_6hUfSrbPmK_x8KS-tOsczLXYqqo.css

This suggests that the aggregated CSS files aren't being gzipped by Drupal?

3 Answers 3

3

As MPD says the options in the performance screen only concatenated and minify the files.

To also Gzip you should turn it on in your Apache config or .htaccess

<IfModule mod_deflate.c>
  <FilesMatch ".(js|css|html|php|txt)$">
    SetOutputFilter DEFLATE
  </FilesMatch>
</IfModule>      
6

There is a difference. You are seeing aggregated (ie, concatenated) and minified CSS when you tick that option on the performance page.

That YSlow report is talking about the webserver sending the results compressed responses the wire. I honestly can't remember if there is a Drupal option for output compression as I always use mod_deflate rules to do this.

Typically, I add the rules directly to the Apache config for my whole server (so I don't have to worry about core updates nuking my .htaccess file). Lately, I have been using the rules from HTML5 Boilerplate:

<IfModule mod_deflate.c>
  # Force deflate for mangled headers developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping/
  <IfModule mod_setenvif.c>
    <IfModule mod_headers.c>
      SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
      RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
    </IfModule>
  </IfModule>

  # HTML, TXT, CSS, JavaScript, JSON, XML, HTC:
  <IfModule filter_module>
    FilterDeclare   COMPRESS
    FilterProvider  COMPRESS  DEFLATE resp=Content-Type $text/html
    FilterProvider  COMPRESS  DEFLATE resp=Content-Type $text/css
    FilterProvider  COMPRESS  DEFLATE resp=Content-Type $text/plain
    FilterProvider  COMPRESS  DEFLATE resp=Content-Type $text/xml
    FilterProvider  COMPRESS  DEFLATE resp=Content-Type $text/x-component
    FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/javascript
    FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/json
    FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/xml
    FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/xhtml+xml
    FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/rss+xml
    FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/atom+xml
    FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/vnd.ms-fontobject
    FilterProvider  COMPRESS  DEFLATE resp=Content-Type $image/svg+xml
    FilterProvider  COMPRESS  DEFLATE resp=Content-Type $image/x-icon
    FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/x-font-ttf
    FilterProvider  COMPRESS  DEFLATE resp=Content-Type $font/opentype
    FilterChain     COMPRESS
    FilterProtocol  COMPRESS  DEFLATE change=yes;byteranges=no
  </IfModule>

  <IfModule !mod_filter.c>
    # Legacy versions of Apache
    AddOutputFilterByType DEFLATE text/html text/plain text/css application/json
    AddOutputFilterByType DEFLATE application/javascript
    AddOutputFilterByType DEFLATE text/xml application/xml text/x-component
    AddOutputFilterByType DEFLATE application/xhtml+xml application/rss+xml application/atom+xml
    AddOutputFilterByType DEFLATE image/x-icon image/svg+xml application/vnd.ms-fontobject application/x-font-ttf font/opentype
  </IfModule>
</IfModule>

Note that this works on MIME type, and not file extensions, so more respones from Drupal will get compressed.

1

Just came across this while looking for something else. I too wondered if the gzip versions of my css files were being served. I posted my findings on this here:

https://drupal.org/node/2162911

Hopefully it'll help anybody coming across this (and people can comment on its accuracy or otherwise).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.