Client-side optimization techniques can only take you so far. You can squeeze only so many bytes out of that GIF, JavaScript, or XHTML page. But as you'll discover, with server-side techniques, you can squeeze even more speed and HTTP requests out of popular pages. The idea is to shunt code from the client to the server, and let the server do more of the work. This chapter covers the following topics: conditional includes, browser sniffing, automatic URL abbreviation, form and CGI optimization, and faster Perl scripts with mod_perl.
Figures
- Figure 17.1 - Peter Belesis' DHTML hierarchical menus
- Figure 17.2 - BrowserHawk detecting environment variables
Code Listings
The chapter goes on to discuss URL abbreviation with mod_rewrite, which can save up to 20 to 30% off high traffic pages with many links.
Summary
Client-side web site optimization can take you only so far. To fully optimize high-traffic
pages, you've got to turn to the server-side. By configuring your server to accommodate conditional SSI and browser sniffing, abbreviated URLs, and shunting defaults to the server, you can dramatically speed up your pages. Here is a list of key points in this chapter:
- Use SSI to minimize HTTP requests on high-traffic pages.
- Where possible, pre-merge dynamic content without SSI for maximum speed.
- Use server-side browser sniffing to minimize HTTP requests, especially for
JavaScript files. Use the fastest technology available (JSP > PHP > XSSI).
- Conditionally include meta tags.
- Abbreviate your links, manually or automatically, with mod_rewrite and
shorturls.pl (20 to 28 percent savings).
- Optimize your forms and CGI scripts to shunt defaults to the server.
- Use mod_perl to speed up Perl scripts.
- Don't require www. for your domains.
Further Reading
Books
- Apache Server 2.0: The Complete Reference
- By Ryan Bloom (Osborne
McGraw-Hill, 2002). The first book on Apache 2.0 by one of the developers.
- Professional Apache 2.0
- By Peter Wainwright, et al. (Wrox, 2002). Includes a chapter on performance.
- Web Performance Tuning, 2nd ed.
- By Patrick Killelea (O'Reilly, 2002). The definitive guide to tuning your server.
Articles
- Apache Performance Notes
- Miscellaneous performance tuning tips from the Apache organization.
- Extreme HTML Optimization
- Radical reductions with no-holds-barred techniques, including URL rewriting. By Andrew King.
- URLS! URLS! URLS!
- An article on URL rewriting from A List Apart by Bill Humphries.
Apache XSSI
CGI/HTTP
DHTML Hiermenus Information (sniffing)
PHP Sniffers
Browscap and Browserhawk
URL Abbreviation
- Apache
- CMS
- Cocoon An open source web application platform based on XML and XSLT that can perform URL rewriting and much more.
- Manila
- Zope
- Microsoft IIS
- WebReference.com scripts includes automatic URL abbreviation script and documentation (free)
mod_perl
- mod_perl (use Apache::PerlRun and Apache::Registry)