Server Modules: Apache Modules, ISAPI, and Others

 <  Day Day Up  >  


One serious problem with CGI programs is performance. There are two reasons that CGI programs can be slow. First of all, the launch of the CGI program by the Web server can itself be slow. Then, once launched, the program might run relatively slowly because it is written in an interpreted language such as Perl. Solving the second problem is easy: simply rewrite the program in a compiled language such as C. Performance should quickly improve. What about the launch problem? One approach would be to pre-launch the main CGI program so that it is running all the time, and have smaller CGI programs launch when needed. Although this would help, the server still would have to communicate with an external program, which does incur a performance penalty because the operating system must switch between programs.

If speed is really an all-consuming issue, it would be best for the CGI to be native to the Web server itself. This is the idea behind a Web server API module. The basic idea is that the server-side program is written to be a component of a Web server. There are many types of server modules and they are typically associated with a particular server. For example, on the Microsoft Web server IIS, Internet Server Application Programming Interface (ISAPI) programs can be written to extend the server. On the older Netscape server, NSAPI programs could be written. Apache servers have Apache modules. Servers with Java capability would use Java servlets, and so on. Collectively, we will refer to these server programs simply as server modules.

A server module is an extension for a particular Web server that is typically written in C or C++ and conforms to a particular server application programming interface (API). Obviously, given the various server-specific details and the need for a language like C or C++, writing a server module is much more difficult than writing a simple CGI program. There are other drawbacks as well. For example, a misbehaving server module can bring a whole server down. Developers who write a server module - based solution also might be stuck using a particular server platform, whereas CGI programs generally are portable from server to server. Regardless of their drawbacks, server modules have the advantage of speed and the capability to share data across sessions and users very easily. With this power, many third-party developers have created server extensions to extend a Web server. A list of Apache modules can be found at http://modules.apache.org/, while ISAPI filters and extensions can be found at http://www.iismodules.com.

Although most developers are about as likely to write custom server modules as they are to write browser plug-ins, the technology has enabled the creation of server-side scripting technology, which is useful to almost every Web page developer.



 <  Day Day Up  >  


HTML & XHTML
HTML & XHTML: The Complete Reference (Osborne Complete Reference Series)
ISBN: 007222942X
EAN: 2147483647
Year: 2003
Pages: 252
Authors: Thomas Powell

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net