View previous topic :: View next topic |
Author |
Message |
TRUSTAbyss -
Joined: 29 Oct 2003 Posts: 3752 Location: USA, GA
|
Posted: Thu Mar 31, 2005 12:16 am Post subject: PHP Gzip Compression [Updated] |
|
|
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 |
|
|
k1ll3rdr4g0n -
Joined: 04 Jul 2004 Posts: 609
|
Posted: Thu Mar 31, 2005 12:55 am Post subject: |
|
|
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 |
|
|
TRUSTAbyss -
Joined: 29 Oct 2003 Posts: 3752 Location: USA, GA
|
Posted: Thu Mar 31, 2005 1:01 am Post subject: |
|
|
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 |
|
|
MonkeyNation -
Joined: 05 Feb 2005 Posts: 921 Location: Cardiff
|
Posted: Thu Mar 31, 2005 1:44 am Post subject: |
|
|
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 |
|
|
TRUSTAbyss -
Joined: 29 Oct 2003 Posts: 3752 Location: USA, GA
|
Posted: Thu Mar 31, 2005 4:08 am Post subject: |
|
|
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 |
|
|
goose -
Joined: 17 Sep 2002 Posts: 608 Location: The Land Of OZ! come here toto!
|
Posted: Thu Mar 31, 2005 5:56 pm Post subject: |
|
|
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 |
|
|
Moxxnixx -
Joined: 21 Jun 2003 Posts: 1226 Location: Florida
|
|
Back to top |
|
|
AbyssUnderground -
Joined: 31 Dec 2004 Posts: 3855
|
Posted: Thu Mar 31, 2005 6:09 pm Post subject: |
|
|
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 |
|
|
MonkeyNation -
Joined: 05 Feb 2005 Posts: 921 Location: Cardiff
|
Posted: Thu Mar 31, 2005 6:11 pm Post subject: |
|
|
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 |
|
|
TRUSTAbyss -
Joined: 29 Oct 2003 Posts: 3752 Location: USA, GA
|
Posted: Wed Jul 26, 2006 11:39 pm Post subject: |
|
|
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 |
|
|
|