The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> PHP Page Compression, Page compression for faster page display
crowdogs
post Dec 27 2010, 01:59 PM
Post #1


Member
***

Group: Members
Posts: 37
Joined: 25-April 10
From: Indiana
Member No.: 11,731



I've seen somewhere were this bit of php code, as the first line in the HTML (.php) document, is purported to compress the document prior to delivery to the web browser thereby speeding page display. Is this simply too good to be true?
CODE

<?php if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) ob_start("ob_gzhandler"); else ob_start(); ?>
<!DOCTYPE HTML>
<html>...
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Dec 27 2010, 02:11 PM
Post #2


.
********

Group: WDG Moderators
Posts: 9,661
Joined: 10-August 06
Member No.: 7



gzip does exist: http://en.wikipedia.org/wiki/Gzip but my impression is that it speeds up download (due to smaller file size) rather than display. Page rendering might even be slightly slower since the HTML document must first be decompressed.

Can't say if it's worth compressing HTML documents, unless you run high-traffic sites and want to keep costs down. You can reduce the total amount of bandwidth by avoiding bloated tag soup, though --in addition, HTML, HEAD and BODY tags are actually optional in HTML4, and you can leave out the end tags of elements like P, LI, TR, TD etc, as well as any code formatting.

If you just want to make pages load faster for the user, you can make many smaller pages instead of a few large ones. But while each individual small page downloads faster, the total bandwidth for viewing them all will become larger since each page needs its own HEAD section, menu markup, etc.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
crowdogs
post Dec 27 2010, 03:25 PM
Post #3


Member
***

Group: Members
Posts: 37
Joined: 25-April 10
From: Indiana
Member No.: 11,731



I've misstated, I should have said, to speed download time.

You've made an interesting observation: "Page rendering might even be slightly slower since the HTML document must first be decompressed."

I did try a few pages and could discern no difference in "page rendering". But, there are still those using 56k modems--god bless 'em--that might be able to tell a difference.

Then again, I might be unreasonably concerned with the the issue.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Dec 27 2010, 04:02 PM
Post #4


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,733
Joined: 9-August 06
Member No.: 6



I'd say, to the viewer, it's the total time it takes from the URL is requested to when the page can be read that matters. Who can tell the difference anyway, if there isn't a serious problem somewhere along the line?

I think the oneliner you posted assumes the server is Apache and that mod_gzip is installed. It still isn't built in, I think. There's also a way to do it with PHP alone, but I'm to lazy to google it up. Shouldn't be hard to find.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Dec 27 2010, 06:23 PM
Post #5


.
********

Group: WDG Moderators
Posts: 9,661
Joined: 10-August 06
Member No.: 7



QUOTE(crowdogs @ Dec 27 2010, 09:25 PM) *

You've made an interesting observation: "Page rendering might even be slightly slower since the HTML document must first be decompressed."

I did try a few pages and could discern no difference in "page rendering".

Yes probably the delay is not noticeable.

QUOTE
But, there are still those using 56k modems--god bless 'em--that might be able to tell a difference.

True. Of course images or Flash often cause longer download times then the HTML files, but you can't compress the former more than they already are. Javascript files/libraries might be possible to gzip though (I don't know).
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Dec 28 2010, 01:24 AM
Post #6


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,733
Joined: 9-August 06
Member No.: 6



Text is text.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
stjepan
post Jan 2 2011, 12:00 PM
Post #7


Serious Coder
*****

Group: Members
Posts: 329
Joined: 15-October 06
From: zagreb, croatia
Member No.: 445



I turned on compression on my website and saw a dramatic improvements, it can be measured in milliseconds smile.gif Now, really, the design and programming is where the focus should be (pictures size, php and sql funcions...), and if that is done right you'll see no big difference between compressed and non-compressed content. You shouldn't be worried to much about compression.

This post has been edited by stjepan: Jan 2 2011, 12:01 PM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 27th April 2024 - 08:42 PM