Log in Sign up
Back to Discover
💻

Common Gateway Interface

technology Maturity 9-11

Web pages can do more than just show pictures.

Common Gateway Interface logo.svg
Common Gateway Interface logo.svg
They can talk to you. When you click a button, a special program works. It helps the page change for you. It makes the web fun! Do you like to click buttons?

45 words

Web pages can do more than show pictures.

Common Gateway Interface logo.svg
Common Gateway Interface logo.svg
They can talk to you. This happens using a special tool.

When you fill out a form, you send data. The web server gets this data. Then, the server starts a new program.

This program looks at your data. It makes a new page for you. The server sends that page to your screen.

This tool was made in the early 1990s. It was the first way to make pages interactive.

It acts like a gateway. It connects the web to other systems. It makes the web very useful!

101 words

Web pages can do more than show pictures. They can talk to you! This happens through a tool called CGI. CGI stands for Common Gateway Interface. It acts like a bridge or a gateway. It connects a web server to other computer systems.

Common Gateway Interface logo.svg
Common Gateway Interface logo.svg

Here is how the way works. First, a user fills out a form on a page. When they click submit, the data goes to the web server. The server then starts a new program called a CGI script. This script is a set of steps that processes the data. The script makes a new page, often using HTML. The server then sends this new page back to your browser.

CGI was made in the early 1990s. It was the first way to make web pages interactive. People used it to connect databases to the web. However, CGI can be slow. This is because the server must start a new process for every single request. It must also destroy that process when it is done. This uses a lot of computer power. Because of this, people made new ways to handle web data.

189 words

Web pages can do much more than just show you static pictures or text. They can actually talk to you and respond to what you do. This magic happens through a tool called the Common Gateway Interface, or CGI. CGI acts like a bridge or a gateway between a web server and other computer systems. It allows a web server to run an external program to handle user requests. Without this, the web would be a much quieter place.

Common Gateway Interface logo.svg
Common Gateway Interface logo.svg

When you use a web page, the way it works follows a specific set of steps. First, you might fill out a form on a website and click a submit button. This action sends your data to the web server inside an HTTP request. The server then launches a CGI script as a new computer process. This script takes your data and does some work with it. Usually, the script creates a new page using HTML. Finally, the server sends that new page back to your browser as a response.

Common Gateway Interface logo.svg
Common Gateway Interface logo.svg

CGI was a very important invention in the early 1990s. It was the earliest common way to make web pages interactive. In 1993, a team from the National Center for Supercomputing Applications (NCSA) wrote the first specification. They shared this idea on a mailing list called www-talk. Other developers saw how useful it was and began using it. This helped make CGI a standard for web servers everywhere. Later, in November 1997, a group led by Ken Coar worked to make these rules even more formal.

Common Gateway Interface logo.svg
Common Gateway Interface logo.svg

Many important people helped shape how CGI works today. The formal rules, known as RFC 3875, included help from many experts. Rob McCool wrote the NCSA HTTPd server, and John Franks wrote the GN web server. Ari Luotonen worked on the CERN httpd server. Tony Sanders worked on the Plexus server, and George Phillips helped at the University of British Columbia. These people helped ensure that different web servers could all use the same language. This made it much easier for programmers to write scripts that worked on any server.

Common Gateway Interface logo.svg
Common Gateway Interface logo.svg

Even though CGI is old, it is still used in many places today. You can find it in well-known software like Apache and Microsoft IIS. However, CGI has a hard job because it must start a new process for every single request. This can use a lot of computer memory and power. Because of this, people created faster alternatives like FastCGI or SCGI. These newer ways allow programs to stay running instead of starting and stopping constantly. Just like how a bridge connects two lands, CGI connected the early web to the big databases of the past.

458 words

The Common Gateway Interface, or CGI, is a vital specification for web computing. It allows a web server to execute external programs to process user requests sent via HTTP or HTTPS. In the early days of the internet, web servers were mostly used to send static files. These files, like a simple text document or a picture, do not change. CGI changed this by allowing the server to create pages on the fly. This makes the web interactive rather than just a collection of digital books.

Common Gateway Interface logo.svg
Common Gateway Interface logo.svg

To understand the mechanism, we must look at how a request moves through a system. When a user interacts with a web page, such as clicking a submit button on a form, the browser sends an HTTP request to the server. This request contains specific data from the user. The web server receives this and launches a CGI script as a new computer process. The server passes the user's data to the script using environment variables or standard input. For example, if a user sends a query string, it is stored in a variable called QUERY_STRING. The script processes this data and produces an output, which is usually HTML code. The web server then takes this output and relays it back to the user's browser as a response.

CGI programs can be categorized by how they are written and executed. Many are called CGI scripts because they are written in scripting languages. However, they can also be compiled programs written in languages like C. Historically, C was very common for this work. The specification RFC 3875 even uses C to define how environment variables are accessed. Another way to categorize them is by their deployment method. Some servers use a special directory, often named cgi-bin, to keep executable files secure. Others identify scripts by using specific filename extensions, such as .cgi. While convenient, using extensions can sometimes create security risks if a user uploads malicious code.

Common Gateway Interface logo.svg
Common Gateway Interface logo.svg

The history of CGI is rooted in the early 1990s. In 1993, a team from the National Center for Supercomputing Applications (NCSA) wrote the first specification. They shared it on the www-talk mailing list to help developers call command line executables. Because it was so useful, other web server developers adopted it quickly. In November 1997, a work group chaired by Ken Coar began formalizing the NCSA definition. This effort resulted in RFC 3875, which established CGI Version 1.1. This document included contributions from many experts, such as Rob McCool, John Franks, Ari Luotonen, Tony Sanders, and George Phillips.

The name "gateway" reveals the original purpose of this technology. In the early web era, webmasters needed to connect modern web servers to legacy information systems. These older systems often included large, complex databases. CGI acted as the bridge, or gateway, between the new web interface and the old data systems. A common modern example is a wiki. When a user requests a wiki page, a CGI program retrieves the source data, transforms it into HTML, and displays it. If the user clicks an edit button, the program can then update the source and save the changes back to the system.

Despite its importance, CGI has a significant technical limitation regarding efficiency. For every single incoming request, the web server must create a new process and then destroy it once the work is done. This constant starting and stopping consumes a lot of CPU time and memory. If a website receives a very high number of requests, this overhead can overwhelm the server. To solve this, developers created several alternatives. Some use web server extensions, like Apache modules, to keep processes running longer. Others use protocols like FastCGI, SCGI, or AJP. These allow application processes to stay active and listen on a socket, which uses much less memory than the standard CGI method.

Common Gateway Interface logo.svg
Common Gateway Interface logo.svg

Security is another critical aspect of using CGI. Because these scripts run in the security context of the web server, they must be handled carefully. In early 1996, a widespread security issue occurred involving a script called PHF. This script was intended to be a simple phone book, but it did not properly sanitize user input. This allowed attackers to perform what is known as a code injection attack. By passing specific characters, an attacker could run unauthorized commands on the server. This event served as a major lesson for the computing world about the dangers of unsanitized data. Today, CGI remains a foundational concept that connects the user to the complex systems running behind every website.

763 words
🖼️ Images & Media (1)
File:Common Gateway Interface logo.svg
Common Gateway Interface logo.svg
Up Next
💻
API
Technology
More to explore

🔬 Go deeper

More advanced topics to explore

🪜 Step back

Simpler topics to build understanding

What is Nepedia?

A free, ad-free encyclopedia for children. Every article is written at five reading levels, so the same page works for a five-year-old and a fifteen-year-old — use the level switcher above to see this one change. No account needed to read.