PDA

View Full Version : Accelerating your pages


sss241
09-15-2005, 01:27 AM
Not quite sure if this is where i should put it, but my pages appear to load faster after puting this line in the index.php

<?php
{
ob_start ("ob_gzhandler");
}

re-upload to your website and presto your site should load much faster....
of course, your webserver should have gzip installed.

you can check if it&#39;s all working at -

http://www.desilva.biz/gzip-test.php

<- just enter your site details

WormBaby
10-26-2005, 12:55 AM
WOW. Thanks man my site is 50 to 80% faster. Rock on man.

thomas
10-26-2005, 02:51 AM
awsome find.

impressive.

Im sure there are other ways possible as well

abcohen
10-26-2005, 03:05 PM
I must be missing something when I insert the line it trys to open the webpage as a save for file dialog....

tokenyank
10-29-2005, 04:02 PM
This worked ok on my SD site

The webpage is COMPRESSED / GZIPPED&#33;

>> Savings: 81%

Filesize: 31.3KB [5.9KB] html / text only[/b]

though don&#39;t add it to a vB install MAJOR GARBISH output&#33;

code_renegade
10-29-2005, 09:11 PM
Excellent find - my site saves an amazing 86% load time now :D

jblackburn
10-30-2005, 06:47 PM
<div class='quotetop'>QUOTE(abcohen &#064; Oct 26 2005, 06&#58;05 AM) 1884</div>
I must be missing something when I insert the line it trys to open the webpage as a save for file dialog....
[/b]

It must be a mix of the correct settings. If I simply add the lines to the pages, I don&#39;t get an error, but the pages still show as "no compression." If I go into php.ini instead and set the output_handler to ob_gzhandler the test shows "compressed" but clicking links trys to open the webpage as a save for file... like you noticed. Note that if the change is made to the php.ini file as well, you must pull the code from the individual page or you&#39;ll get an error saying you can&#39;t use it twice.

jblackburn
11-02-2005, 05:04 AM
Follow up.... it&#39;s working:

1. You need to have the Zlib loaded on your server; you can check that by looking at your php info. See here for instructions on checking if Zlib support is enabled on your server (create the "phpinfo.php" file):

http://www.desilva.biz/php/zlib.html

2. Rather than adding it to individual pages, I added it to the .htaccess file:

Options All -Indexes
Options +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} &#33;-f
RewriteCond %{REQUEST_FILENAME} &#33;-d
RewriteRule ^(.*) index.php

php_flag zlib.output_compression on
php_value zlib.output_compression_level 1

3. The compression level option goes up to 9. I read that there may be a hit on your server at the higher level and that there&#39;s not much difference in setting it at 1, which is what I did.

4. I can&#39;t handle Flash. If you have any on your site, move it into a folder (if it&#39;s not there already - you do organize your files, right :)) and place another .htaccess file in THAT folder with compression off:

php_flag zlib.output_compression off
php_value zlib.output_compression_level 1

5. Test your site here: http://www.desilva.biz/gzip-test.php

Note that you may need to put the actual name of your category in to see the results. For example, if you have a Home category put in http://www.yoursitename.com/Home

You should see that it is compressed&#33; Thx to sss241 for the original info.

artzfx
11-29-2005, 11:01 AM
This is amazing.. what a difference&#33; Thanks for the tip&#33;

william
12-02-2005, 01:42 AM
WHAT A BITCHIN FIND&#33;&#33;&#33; THANKS&#33;&#33;&#33;

Greg Thimmes
12-06-2005, 05:05 PM
Ok I have Zlip loaded on my server, when I add the code to my index.php file my page just shows up blank. How can I get it to work? Any Ideas on why this is happening?

abcohen
12-06-2005, 05:17 PM
greg it didnt work for me either...

dhdesign
01-01-2006, 12:47 PM
<div class='quotetop'>QUOTE(Greg Thimmes &#064; Dec 6 2005, 12&#58;05 PM) 2349</div>
Ok I have Zlip loaded on my server, when I add the code to my index.php file my page just shows up blank. How can I get it to work? Any Ideas on why this is happening?
[/b]

Greg -

Below is the code that I have in the beginning of my index.php, and it works fine for me on Subdreamer Light. Perhaps you placed the code in the wrong part of the file?

&#60;?php
// +---------------------------------------------+
// |**** Copyright © 2003 – 2005 Subdreamer, LLC |
// |**** http&#58;//www.subdreamer.com************** |
// |**** This file may not be redistributed.**** |
// +---------------------------------------------+

define&#40;&#39;IN_SUBDREAMER&#39;, true&#41;;
&#036;rootpath = &#39;./&#39;;

// ############################# ENABLE GZIP COMPRESSION**########################

{
ob_start &#40;&#34;ob_gzhandler&#34;&#41;;
}

// ########################### LOAD SUBDREAMER CORE ############################

fuz@fragstealer.net
01-04-2006, 02:00 PM
How does this actually work? At what level is the compression applied?
How is it affected by dynamic pages that have user profile dependant content?
Is this primarily for large semi static pages?

Squeegie
01-30-2006, 03:20 AM
it basically compress&#39;s your site from a huge file to load to a small one, kinda like putting it in an archive to compress, mine got so fast this is a great find&#33;

87.4% faster&#33;&#33;

Pyromanci
02-27-2006, 03:58 PM
I recommend using this format instead of the strait ob_start ("ob_gzhandler")

This code will find your php version and server setting and handle accordingly. If you don&#39;t have the requirements then it wont do anything.


****&#036;phpver = phpversion&#40;&#41;;

****&#036;useragent = &#40;isset&#40;&#036;_SERVER&#91;&#34;HTTP_USER_AGENT&#34;&#93;&#41; &#41; ? &#036;_SERVER&#91;&#34;HTTP_USER_AGENT&#34;&#93; &#58; &#036;HTTP_USER_AGENT;

****if &#40; &#036;phpver &#62;= &#39;4.0.4pl1&#39; && &#40; strstr&#40;&#036;useragent,&#39;compatible&#39;&#41; || strstr&#40;&#036;useragent,&#39;Gecko&#39;&#41; &#41; &#41;
****{
********if &#40; extension_loaded&#40;&#39;zlib&#39;&#41; &#41;
********{
************ob_start&#40;&#39;ob_gzhandler&#39;&#41;;
********}
****}
****else if &#40; &#036;phpver &#62; &#39;4.0&#39; &#41;
****{
********if &#40; strstr&#40;&#036;HTTP_SERVER_VARS&#91;&#39;HTTP_ACCEPT_ENCODING&#39;&#93;, &#39;gzip&#39;&#41; &#41;
********{
************if &#40; extension_loaded&#40;&#39;zlib&#39;&#41; &#41;
************{
****************&#036;do_gzip_compress = TRUE;
****************ob_start&#40;&#41;;
****************ob_implicit_flush&#40;0&#41;;
****************header&#40;&#39;Content-Encoding&#58; gzip&#39;&#41;;
************}
********}
****}

Usurper
03-03-2006, 05:50 AM
Looks like 2.3 has compression built into it (main settings -> gzip compression). Just curious if this is any different than what&#39;s been officially incorporated into the program.

IGGY
03-03-2006, 06:12 AM
Good question I have tested RC 2.3 but I never tried this mod.

spib
03-03-2006, 07:53 AM
It&#39;s gives the same result as the code in this thread but has a few extra checks

IGGY
03-03-2006, 06:10 PM
Good to know&#33; Thanks.

kaplan
04-05-2006, 01:26 AM
thnx man&#33; that is wonderful.&#33;&#33;&#33;

Robert_J_Ellis
04-07-2006, 06:22 AM
People looking at this, make sure not to use this with the newer rc2. It will cause a conflict by trying to initiate gzip twice.

rc2 uses an .htaccess command to automatically zip files given they math the parameters. This though of course will only work with apache.

If your server is not apache, and you want to try this, this should achieve the same thing.

getyocupsup
04-24-2006, 06:36 AM
Wow... just simply wow

Shap
06-23-2006, 04:28 PM
<div class='quotetop'>QUOTE(Robert_J_Ellis &#064; Apr 6 2006, 10&#58;22 PM) 5007</div>
People looking at this, make sure not to use this with the newer rc2. It will cause a conflict by trying to initiate gzip twice.

rc2 uses an .htaccess command to automatically zip files given they math the parameters. This though of course will only work with apache.

If your server is not apache, and you want to try this, this should achieve the same thing.
[/b]

Two questions. What is rc2 and who&#39;s got a link to actually test the speed of your pages online?

SD has a gzip that I&#39;ve enabled. Will this make it even faster?

abcohen
06-23-2006, 04:47 PM
RC2 was release canidate 2 (which is older then 2.3.x) if you&#39;re using that then you&#39;re gzip command uses pretty much the same code with just alot more checking goign on.
so dont start editing anything...

valdet
07-07-2006, 04:53 PM
with gzip enabled on i dont see any difference with adding that code in index.php

abcohen
07-07-2006, 05:50 PM
it the same code... remove this hack if your running 2.3.x &#33;&#33;&#33;&#33; its already included as the gzip option in the main control

valdet
07-09-2006, 04:11 PM
<div class='quotetop'>QUOTE(abcohen &#064; Jul 7 2006, 04&#58;50 PM) 7675</div>
it the same code... remove this hack if your running 2.3.x &#33;&#33;&#33;&#33; its already included as the gzip option in the main control
[/b]


completely correct..

I tried with SD gzip on and this hack, and it messed up my index.php... folks dont use this hack otherwise your site wont load in SD 2.30.. it will ask to to download some crappy file with unknown characters :D

DarK_AssassiN
07-09-2006, 04:47 PM
I have the latest SD and it works fine. Its actually faster now than it was before....

abcohen
07-09-2006, 05:03 PM
if you use this code at the start of the thread to turn on GZIP plus use the gzip from the admin panel you&#39;ll most likely mess things up... sooo WE WARN YOU A HEAD OF TIME - K - good :)

william
07-09-2006, 06:22 PM
I just found this option last night...I turned it on and WoW, what a difference it made just in FireFox&#33; I am sooooo Glad this is here now&#33; It made such a difference that my members notices right away&#33; Oh not to defer too much since it also is a setting close was the friendly url&#39;s LOVE THAT TOO&#33; GREAT JOB GUYS&#33;&#33;

Community
11-11-2006, 12:06 AM
This makes me real happy person!! Big Kiss :p