menu bandwidth usage

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
Post Reply
Mailman
Beginner
Beginner
Posts: 3
Joined: Thu Jul 22, 2004 1:30 am

menu bandwidth usage

Post by Mailman »

I've noticed this menu uses up a considerable amount of bandwidth. I've been able to reduce the bandwidth usage quite a bit by renaming the menu files to filename.js.php and adding the following to the top of each file:

<? ob_start("ob_gzhandler"); header("Content-type: application/x-javascript"); ?>

This makes every script a PHP file. The code gzips the text before sending to the web browser, but only if the browser supports gzipped pages, which most do.

Still, after this compression the menu still uses up quite a bit of bandwidth. It would be nice if there were a "lite" version that had smaller file sizes.
Mailman
User avatar
Maz
Milonic God
Milonic God
Posts: 1717
Joined: Fri Jun 06, 2003 11:39 pm
Location: San Francisco
Contact:

Post by Maz »

You can compress the menu-data file, leaving no spaces. You can rename it menu-data.php, the thing that takes time is usually images not the menu, and those can be preloaded and are cached, and if the images are the same image used throughout then that helps cut down on loading images.

I find the menus quite fast loading, but then it may depend how complex you are building it. Older browsers don't handle js well will of course not be as fast, but modern browsers are faster.

maz
Mailman
Beginner
Beginner
Posts: 3
Joined: Thu Jul 22, 2004 1:30 am

Post by Mailman »

Its not the speed of the menu loading that I have problems with, its the fact that the menu files use up almost 900MBs of bandwidth a month. We also use no images in the menu. Its the actual script files that are eating up bandwidth.
Mailman
User avatar
John
 Team
 Team
Posts: 5967
Joined: Sun May 19, 2002 8:23 pm
Location: Phoenix, AZ
Contact:

Post by John »

Haven't seen this problem myself, and I have sites of 500+ pages to deal with.

I don't think you're saving anything by zipping stuff. In fact, it seems to me you're putting an extra load on the server.

Any of your pages in an https environment?
John
User avatar
Andy
Milonic
Milonic
Posts: 3308
Joined: Sun May 19, 2002 8:23 pm
Location: Menu Developer
Contact:

Post by Andy »

This question/complaint comes up from time to time and it's so easy to blame the menu for the increase in bandwidth but you've missed the real reason.

The menu files are quite small really and the vast majority of users will have caching switched on in their browsers so the files will only be downloaded once per user per visit, on average 50-60K per website, that's nothing is it?

Think about what you have done by installing a menu system on your website. You've increased your websites ability to serve its pages. Check your logs a little closer and you'll see that you are serving more pages than before (I'll put a bet on it) and this is why your bandwidth usage has increased it's nothing to do with the size of the menu.js files but more to do with the fact that your website is easier to navigate and people are using it more now.

In theory, the menu should be getting much praise for making your website better but alas, we only get complaints. It's Kind of a victim of its own success.

Cheers
Andy
Mailman
Beginner
Beginner
Posts: 3
Joined: Thu Jul 22, 2004 1:30 am

Post by Mailman »

You know, making the js files into PHP files is probably forcing the browser to reload the script every time someone visits a page, defeating the purpose of compressing it. I bet if I added some cache control to the script, I could have the best of both worlds: fast loading and low bandwidth usage.

Thanks for the replies.
Mailman
Post Reply