關於 PHP, Linux, Open Source 及個人生活記載的網誌。
RSS icon
  • 使用 PHP GZIP 使網頁提速

    Posted on February 22nd, 2010 Sam Tang No comments

    GZIP 是一種壓縮技術,是在伺服器上將頁面壓縮,傳到用戶的瀏覽器再解壓。在 PHP 實要 GZIP 壓縮可以這樣做:

    PHP:
    1. <?php
    2. if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')){
    3.     ob_start("ob_gzhandler");
    4. }else{
    5.     ob_start();
    6. }
    7. ?>


    Leave a reply

    *
    To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
    Click to hear an audio file of the anti-spam word