We Recommend

Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems
Wicked Cool PHP contains a wide variety of scripts to process credit cards, check the validity of email addresses, template HTML, and serve dynamic images and text.


Posted By

johnself on 02/12/08


Tagged

css php gzip obgzhandler


Versions (?)


Who likes this?

8 people have marked this snippet as a favorite

SpinZ
basicmagic
brent-man
maxav
hellion
Netzach
grn
AlastairDewar


Gzipping your CSS


Published in: PHP 


URL: http://www.fiftyfoureleven.com/weblog/web-development/css/the-definitive-css-gzip-method

CSS files for larger sites can become pretty large themselves. Gzipping or compressing these files has shown to provide a reduction in the neighborhood of 70-80% of the original file size, a fairly significant 'weight loss'.

  1. <?php
  2. ob_start ("ob_gzhandler");
  3. header("Content-type: text/css; charset: UTF-8");
  4. header("Cache-Control: must-revalidate");
  5. $offset = 60 * 60 ;
  6. $ExpStr = "Expires: " .
  7. gmdate("D, d M Y H:i:s",
  8. time() + $offset) . " GMT";
  9. header($ExpStr);
  10. ?>

Report this snippet 

You need to login to post a comment.