основное назначение скрипта - сжатие страниц, передаваемых сервером браузеру. у меня в среднем сжималось в 4 раза. одно "но": не ставьте уровень сжатия больше 3 - размер не уменьшится, а нагрузка на сервер - еще как. скрипт используется следующим образом: ... the page ... gzdoc.php /* ** title.........: php4 http compression speeds up the web ** version.......: 1.20 ** author........: catoc ** filename......: gzdoc.php ** last changed..: 18/10/2000 ** requirments...: php4 >= 4.0.1 ** php was configured with --with-zlib[=dir] ** notes.........: dynamic content acceleration compresses ** the data transmission data on the fly ** code by sun jin hu (catoc) ** most newer browsers since 1998/1999 have ** been equipped to support the http 1.1 ** standard known as "content-encoding." ** essentially the browser indicates to the ** server that it can accept "content encoding" ** and if the server is capable it will then ** compress the data and transmit it. the ** browser decompresses it and then renders ** the page. ** ** modified by john lim (jlim@natsoft.com.my) ** based on ideas by sandy mcarthur, jr ** usage........: ** no space before the beginning of the first `` tag. ** ------------start of file---------- ** | ** | ** |... the page ... ** | ** | ** -------------end of file----------- */ ob_start(); ob_implicit_flush(0); function checkcangzip(){ if (headers_sent() || connection_aborted()){ return 0; } if (strpos($_server[`http_accept_encoding`], `x-gzip`) !== false) return "x-gzip"; if (strpos($_server[`http_accept_encoding`], `gzip`) !== false) return "gzip"; return 0; } /* $level = compression level 0-9, 0=none, 9=max */ function gzdocout($level=3, $debug=0){ $encoding = checkcangzip(); if ($encoding){ print " use compress $encoding --> "; $contents = ob_get_contents(); ob_end_clean(); if ($debug){ $s = " not compress length: ".strlen($contents)."; "; $s .= "compressed length: ". strlen(gzcompress($contents, $level)). " "; $contents .
Copyright 2010 - All rights reserved Your Company name
Related Posts
Many Tags
May 2, 2008Readability Test
May 1, 2008Many Tags
May 2, 2008Readability Test
May 1, 2008