Common Gateway Interface

What Does Common Gateway Interface Mean?

Common Gateway Interface (CGI), in the the context of web development, is an interface for running executables via a web-server. In most intances, this means taking an HTTP request and passing it to an application in order to deliver a dynamically-generated HTML page back to a browser. While pretty much any program that can run on a web server is usable as a CGI script, Perl is the most popular language.

Advertisements

The standard for CGI is defined in RFC 3875.

Techopedia Explains Common Gateway Interface

In the early days of web development CGI was one of the few ways to provide interactivity in a web application. It was most common on Apache, but ports were made to run CGI on IIS as well.

The most common usage of CGI is using scripting languages, and so it’s common to refer to this as running a CGI script. CGI programs and scripts are usually collected in a folder named /cgi-bin/.

The main disadvantage of CGI is that each page load incurs overhead by having to load the programs into memory. Data cannot easily be cached in memory between page loads. Because of this disadvantage, many developers have moved to application servers that remain running. However, there is a huge existing code base, much of it in Perl. Proponents of CGI argue that it is simple, stable, and a good choice for certain applications, especially involving tasks where Perl excels, such has text handling. Workarounds also avoid loading in the Perl or PHP runtime for each request by including the runtime in the web server (mod_perl and mod_php in Apache), or other solutions such as FastCGI (separate processes that handle multiple requests).

Advertisements

Related Terms

Latest DevOps Terms

Related Reading

Margaret Rouse

Margaret Rouse is an award-winning technical writer and teacher known for her ability to explain complex technical subjects to a non-technical, business audience. Over the past twenty years her explanations have appeared on TechTarget websites and she's been cited as an authority in articles by the New York Times, Time Magazine, USA Today, ZDNet, PC Magazine and Discovery Magazine.Margaret's idea of a fun day is helping IT and business professionals learn to speak each other’s highly specialized languages. If you have a suggestion for a new definition or how to improve a technical explanation, please email Margaret or contact her…