Compress method to speed up loading of the website with PHP
The main advantages 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 file into smaller ones. There are several ways to do this, the way that until now I use is the compression method ob_gzhandler.
How to use it is to insert the following code at the top of each page:
PHP Code:
PHP Code:
Keep in mind, each insert CSS file in the PHP code should be renamed the .php extension. Then import the file into your pages with code:
How to use it is to insert the following code at the top of each page:
PHP Code:
<?php ob_start("ob_gzhandler");?>
In the actual case, the code is not just as simple as that. But enough with the code above course you can see the results of your website loading speed difference from before is added the above code.
Additionally, you can also compress CSS and other files on your website, so it can work faster as well. Because CSS is very different from PHP, you need to add some code php 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, each insert CSS file in the PHP code should be renamed the .php extension. Then import the file into your pages with code:
Code:
Hopefully useful and thank you for visiting this blog.
<link rel="<lokasi>/<nama file .php>" type="text/stylesheet" />
Hopefully useful and thank you for visiting this blog.
Source: klikedukasi.com







