Thank you for taking the time to visit my personal website. Hopefully the information I have presented on this site can be useful and there is knowledge.

Thursday, July 14, 2011

Compresing methods to speed up website loading PHP


The main advantage of using PHP is that you can compress your PHP files, so it can make the time to display the website to be faster because the capacity of the downloaded files into smaller ones. There are several ways to do this, the way that until now I use is with the ob_gzhandler compression method.

How to use it is to insert the following code at the top of every page:

PHP Code:
<?php ob_start ( "ob_gzhandler" ); ?>
In the actual case, the code is not just that simple. However, enough with the code above only you can see the result of differences in the loading speed of your website before adding the above code.

In addition, you can also compress the CSS file and the other on your website, so it can work faster, too. Because CSS is very different from PHP, you need to add some php code header, the following is an example:

PHP Code:
<?php
ob_start
 ( "ob_gzhandler" ); header ( "Content-type: text/css" ); header ( "Cache-Control: must-revalidate" ); $offset = 60 * 60 $ExpStr = "Expires: " . gmdate ( "D, d M Y H:i:s" , time () + $offset ) . " GMT" header ( $ExpStr ); ?>
Keep in mind, any CSS files that are inserted PHP code should be renamed the extension. Php. Then import that file into your page with the code:

Code:
 <Link rel = "<lokasi> / name> .php> file" type = "text / stylesheet" /> 
Hopefully helpful,
root [at] okea.biz
http://www.einu.net

No comments:

Post a Comment