GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 22-Jun-2003, 09:38
Allowee's Avatar
Allowee Allowee is offline
Regular Member
 
Join Date: May 2003
Location: The Netherlands
Posts: 339
Allowee has a spectacular aura about

When to use gzip


I got this script from a site somewhere....

this is just the header..
PHP Code:

//// gzip_compression//$do_gzip_compress = FALSE;if ( $gzip_compress ){    $phpver = phpversion();    $useragent = (isset($_SERVER["HTTP_USER_AGENT"]) ) ? $_SERVER["HTTP_USER_AGENT"] : $HTTP_USER_AGENT;   if ( $phpver >= '4.0.4pl1' AND ( strstr($useragent,'compatible') OR strstr($useragent,'Gecko') ) ){     if ( extension_loaded('zlib') ){            ob_start('ob_gzhandler');        }   }else if ( $phpver > '4.0' AND ( strstr($useragent,'compatible') OR strstr($useragent,'Gecko') )){     $accept_encoding = (isset($_SERVER["HTTP_ACCEPT_ENCODING"]) ) ? $_SERVER["HTTP_ACCEPT_ENCODING"] : $HTTP_ACCEPT_ENCODING;        if ( strstr($accept_encoding, 'gzip') ){            if ( extension_loaded('zlib') ){                $do_gzip_compress = TRUE;                ob_start();                ob_implicit_flush(0);                header('Content-Encoding: gzip');            }        }    }} 



But, do i need to check the browser?
your gzip test script doesn't work when i put http://69.49.231.162/index.php in it.
but when you look at the headers from a normal browser it does work.

is checking for the accept_encoding enough?
__________________
Pastebin
PHP Documentation Site
Allowee's Blog http://allowee.net
  #2  
Old 22-Jun-2003, 09:57
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
If the gzip test says that the web page is not gzipped, chances are that it is not.

I only know of one bug so far (with gziptest) and that was something that was to do with the percentage calculations for 'special' web pages.

I don't know much about these pre-PHP version 4.0.6 hacks for compressing your web pages, but with .htaccess php_flag and ob_start('ob_gzhandler') methods, the script will send compressed or non-compressed output to a browser automatically - otherwise I would have had a serious mess with all the search-engine bots by now.
  #3  
Old 22-Jun-2003, 10:57
Allowee's Avatar
Allowee Allowee is offline
Regular Member
 
Join Date: May 2003
Location: The Netherlands
Posts: 339
Allowee has a spectacular aura about
I'll remove the browser checks and also the php version checks...

i'll add 1 check for the version... just i case.

btw, do you know what i think about your script when i saw
http://Leknor.com/code/gziped.php in my log?

I think your version looks nicer
__________________
Pastebin
PHP Documentation Site
Allowee's Blog http://allowee.net
  #4  
Old 22-Jun-2003, 11:15
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
That was ME I used the script at leknor to verify results from gziptest.

... and about my script looking better - it's only normal since mine is newer. Wait till you see his next upgrade...
 
 

Recent GIDBlogProblems with the Navy (Chiefs) by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
zlib and/or gzip SloppyGoat Apache Web Server Forum 4 17-Dec-2003 15:22

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 03:07.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.