Something Different In Linux

Home » How to » How to compress CSS with gZIP

How to compress CSS with gZIP

Posted by Rishikesh Vispute Categories: How to, Knowledge, PHP

How to compress my CSS with gZIP?

To compress your CSS files with gZIP there are two things that you should do.

First, add the following line to the .htaccess file in your public_html folder:

AddHandler application/x-httpd-php52 .css

By doing this, you allow the server to process .css files through PHP.

Next, add the following lines at the very beginning of your .css file(s):

ob_start (“ob_gzhandler”);
header(“Content-type: text/css; charset: UTF-8”);
header(“Cache-Control: must-revalidate”);
$offset = 60 * 60 ;
$ExpStr = “Expires: ” .
gmdate(“D, d M Y H:i:s”,
time() + $offset) . ” GMT”;

By doing this, you will enable the gZIP compression for your CSS file. For bigger websites there will be a significant improvement in the loading speed of your pages.

Popular Posts

remove index.php fro

How to remove index.php from url in magento Ans : If you ...

PHP-Java bridge on p

  What is php-java bridge? The php-java bridge is the php ...

Set expiration for y

If you want to set the expiration to your site ...

Warning: Parameter 1

Error: Warning: Parameter 1 to modMainMenuHelper::buildXML() expected to be a ...

domain pointing to e

If you domain uses external MX record and it is ...