Computer Dictionary/Common Gateway Interface

programs from a World-Wide WebHTTPserver. CGI
specifies how to pass arguments to the program as part of
the HTTP request. It also defines a set of [[Computer Dictionary/environment
variables|environment
variables]] that are made available to the program. The
program generates output, typically HTML, which the web
server processes and passes back to the browser.
Alternatively, the program can request URL redirection. CGI
allows the returned output to depend in any arbitrary way on
the request.

The CGI program can, for example, access information in a
database and format the results as HTML. The program can
access any data that a normal application program can, however
the facilities available to CGI programs are usually limited
for security reasons.

Early web servers required all CGI programs to be installed in
one directory called cgi-bin but it is much better to keep
them with the HTML files to which they relate unless they are
truly global to the site. All modern web servers make this
easy. Similarly, it is neither necessary nor desirable for
all CGI programs to have the extension ".cgi", especially on
Microsoft Windows servers.

Each CGI request is handled by a new process. If the process
fails to terminate for some reason, or if requests are
received faster than the server can respond to them, the
server may become swamped with processes. In order to improve
performance, Netscape devised NSAPI and Microsoft
developed the ISAPI standard which allow CGI-like tasks to
run as part of the main server process, thus avoiding the
overhead of creating a new process to handle each CGI
invocation.