PHP Gzip Compression [Updated]

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
TRUSTAbyss
-


Joined: 29 Oct 2003
Posts: 3752
Location: USA, GA

PostPosted: Thu Mar 31, 2005 12:16 am    Post subject: PHP Gzip Compression [Updated] Reply with quote

Edit: This was a PHP issue I was having. I would like it to be moved to the
tutorials now if possible. Thank You!


Using PHP you can greatly reduce bandwidth being sent to your visitors by
compressing the pages on the fly. Enjoy!

Using this Gzip Content Compression:

Install PHP and declare the HTML file extensions as Associated Extensions
in the Scripting Parameters for PHP. Now use the following code.

PHP Installation
http://www.trustabyss.com/php_install.html

Code:
<?php
ob_start("ob_gzhandler");
?>
<!-- Insert HTML -->


Note: The Gzip isn't enabled on a Mac, Linux type of OS. You need to manually
compile PHP in order to get this extension enabled on other OS's.

Compressing CSS Code!

Code:
<style type="text/css">
<!--
<?php
include("external_style.css");
?>
-->
</style>


The following CSS code should be included in the html pages with the
Gzip Content Compression code above. You will need to do this to all
of your CSS included web pages.

Replace this CSS code with the external style sheet code. Since this
same file will be included in every page, you don't need the external
style sheet code. This will compress your HTML and CSS.

Note: Replace the CSS file path with yours.

Note: This could even work with your exteral JavaScript files in the exact
same way. Just replace the style sheet tags with JavaScript ones.

Testing your Gzip
http://www.gidnetwork.com/tools/gzip-test.php


Last edited by TRUSTAbyss on Sat Jul 29, 2006 9:23 pm; edited 24 times in total
Back to top View user's profile Send private message Visit poster's website
k1ll3rdr4g0n
-


Joined: 04 Jul 2004
Posts: 609

PostPosted: Thu Mar 31, 2005 12:55 am    Post subject: Reply with quote

Code:
Example 1. Creating a gzip file

<?php
    $data = implode("", file("bigfile.txt"));
    $gzdata = gzencode($data, 9);
    $fp = fopen("bigfile.txt.gz", "w");
    fwrite($fp, $gzdata);
    fclose($fp);
?>


and uhh..the code button doesnt work :). In fact none of them work. Im using firefox. =\
_________________
Back to top View user's profile Send private message AIM Address
TRUSTAbyss
-


Joined: 29 Oct 2003
Posts: 3752
Location: USA, GA

PostPosted: Thu Mar 31, 2005 1:01 am    Post subject: Reply with quote

This is a tutorial now, so the original text in this reply has been removed.

Last edited by TRUSTAbyss on Sat Jul 29, 2006 7:08 pm; edited 1 time in total
Back to top View user's profile Send private message Visit poster's website
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Thu Mar 31, 2005 1:44 am    Post subject: Reply with quote

I too would love to use this.
I know it can be done as I have seen it in action.
The only site I can think of off hand that does this is http://bsgonlinegames.com, or more speicifially, the game scripts (E.G. Run the test on http://starkingdoms.com/scripts/main.php and it shows up as compressed)
_________________
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
TRUSTAbyss
-


Joined: 29 Oct 2003
Posts: 3752
Location: USA, GA

PostPosted: Thu Mar 31, 2005 4:08 am    Post subject: Reply with quote

This is a tutorial now, so the original text in this reply has been removed.

Last edited by TRUSTAbyss on Sat Jul 29, 2006 7:08 pm; edited 3 times in total
Back to top View user's profile Send private message Visit poster's website
goose
-


Joined: 17 Sep 2002
Posts: 608
Location: The Land Of OZ! come here toto!

PostPosted: Thu Mar 31, 2005 5:56 pm    Post subject: Reply with quote

riddle me this why would you want to compress your webpages anyway?

dont you have enough harddrive space available oh 400 gig is too small!
_________________
living in an armish paradise.....no gates here!

mawuahahaha :)
Back to top View user's profile Send private message
Moxxnixx
-


Joined: 21 Jun 2003
Posts: 1226
Location: Florida

PostPosted: Thu Mar 31, 2005 6:01 pm    Post subject: Reply with quote

goose, there are two main reasons for Gzip Compression...

1. Loads pages faster.
2. Reduces bandwidth.

Read more about it here...
http://webreference.com/internet/software/servers/http/compression/
Back to top View user's profile Send private message Visit poster's website
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Thu Mar 31, 2005 6:09 pm    Post subject: Reply with quote

It doesnt compress them on your hard drive, it compresses them before sending them to the client browser.
_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Thu Mar 31, 2005 6:11 pm    Post subject: Reply with quote

The Inquisitor wrote:
It doesnt compress them on your hard drive, it compresses them before sending them to the client browser.


Which just gave all my pages a kick up the arse! :-)
_________________
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
TRUSTAbyss
-


Joined: 29 Oct 2003
Posts: 3752
Location: USA, GA

PostPosted: Wed Jul 26, 2006 11:39 pm    Post subject: Reply with quote

I just updated the Gzip Tutorial. You now have the option to compress your
CSS and even JavaScript. I also wrote a guide to tell you what you should do
in order to compress your web pages to the maximum extent.

Compressing your page Completely.
http://www.trustabyss.com/success_to_optimization.txt

Note: This was a PHP issue I was having but now I would like it to be moved
to the tutorials if possible. Thank You!

Sincerely, TRUSTAbyss
Back to top View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group