SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    SitePoint Enthusiast pff's Avatar
    Join Date
    Dec 2000
    Location
    Google PageRank: 6
    Posts
    78
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to use GZIP?

    Hello,
    First, I'm a newbie in PHP. My host supports GZIP compression and I have a .php page that has some html code and a few PHP includes in it. I want to display this to my visitors using GZIP compression so that it will load faster. How can I do that?

    Is there a simple copy/paste code that I can use Any help or articles are greatly appreciated.

    Note: I'm looking for a better explanation than this one
    pff | I am not what I am

    'Does he exist in the same way as I exist?'
    'You do not exist Winston,' said O'Brien.

  2. #2
    SitePoint Enthusiast
    Join Date
    May 2001
    Location
    lalal
    Posts
    85
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    just put

    PHP Code:
    ob_start("gz_handler"); 
    at the top of all php pages

  3. #3
    SitePoint Enthusiast pff's Avatar
    Join Date
    Dec 2000
    Location
    Google PageRank: 6
    Posts
    78
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks but my PHP version is 4.0.3pl1 so I can't use that function. Is there another way of doing this because I can use GZIP in vBulletin.
    Last edited by pff; Jul 4, 2001 at 18:34.
    pff | I am not what I am

    'Does he exist in the same way as I exist?'
    'You do not exist Winston,' said O'Brien.

  4. #4
    SitePoint Zealot alexk's Avatar
    Join Date
    Nov 2000
    Location
    Sydney, Australia
    Posts
    134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you can use this code

  5. #5
    Database Jedi MattR's Avatar
    Join Date
    Jan 2001
    Location
    buried in the database shell (Washington, DC)
    Posts
    1,107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by pff
    Thanks but my PHP version is 4.0.3pl1 so I can't use that function. Is there another way of doing this because I can use GZIP in vBulletin.
    output_handler = obgzip or somesuch in your php.ini file. However, if you are using GZip at LEAST get 4.0.5 since it offers much improved (read: far less buggy) gzip handling.

  6. #6
    SitePoint Enthusiast pff's Avatar
    Join Date
    Dec 2000
    Location
    Google PageRank: 6
    Posts
    78
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the help.
    alexk: I tried that one but the bad news is that my host has output buffering turned of in the php config so I can't use it

    There should be another method of doing this because vB manages to use GZIP compression on my host
    pff | I am not what I am

    'Does he exist in the same way as I exist?'
    'You do not exist Winston,' said O'Brien.

  7. #7
    SitePoint Zealot alexk's Avatar
    Join Date
    Nov 2000
    Location
    Sydney, Australia
    Posts
    134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    pff: do you have the access to your php.ini file? If so, do what MattR wrote about. If you don't, well you can use vB code as an example

  8. #8
    SitePoint Enthusiast pff's Avatar
    Join Date
    Dec 2000
    Location
    Google PageRank: 6
    Posts
    78
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Unfortunately I don't, I'm on a shared server and my host isn't planning a php upgrade.
    alexk: Do you in which files the vB GZIP code is?

    Thanks
    pff | I am not what I am

    'Does he exist in the same way as I exist?'
    'You do not exist Winston,' said O'Brien.

  9. #9
    SitePoint Evangelist
    Join Date
    Oct 2000
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    just put



    PHP:--------------------------------------------------------------------------------
    ob_start("gz_handler");--------------------------------------------------------------------------------


    at the top of all php pages


    Would that have to be right at the top of the page? Or will it just compress everything after it? ie is it OK to do it after a couple of lines of html have been sent.

    Does it also compress html that is not between <? ?> tags or just php 'echoed' html?

    Thanks

  10. #10
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Using ob_start("gz_handler"); causes a memory leak doesn't it ?

    Sean

  11. #11
    SitePoint Zealot alexk's Avatar
    Join Date
    Nov 2000
    Location
    Sydney, Australia
    Posts
    134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by pff
    Unfortunately I don't, I'm on a shared server and my host isn't planning a php upgrade.
    alexk: Do you in which files the vB GZIP code is?

    Thanks
    sorry pff, i overlooked your post ... you can find the code in ./admin/functions.php (for 2.0.1 vB version)

  12. #12
    SitePoint Zealot alexk's Avatar
    Join Date
    Nov 2000
    Location
    Sydney, Australia
    Posts
    134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by seanf
    Using ob_start("gz_handler"); causes a memory leak doesn't it ?

    Sean
    AFAIK it does in php 4.0.4, but fixed in next versions...


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •