Common Gateway Interface

Why Trust Techopedia

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

Margaret Rouse
Technology expert
Margaret Rouse
Technology expert

Margaret is an award-winning writer and educator known for her ability to explain complex technical topics to a non-technical business audience. Over the past twenty years, her IT definitions have been published by Que in an encyclopedia of technology terms and cited in articles in the New York Times, Time Magazine, USA Today, ZDNet, PC Magazine, and Discovery Magazine. She joined Techopedia in 2011. Margaret’s idea of ​​a fun day is to help IT and business professionals to learn to speak each other’s highly specialized languages.