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.