Glossary
Common Gateway Interface
CGI is a standard protocol used to enable web servers to interact with external content-generating programs, which are often referred to as CGI scripts or simply gateways. These programs can be written in various programming languages such as C, Perl, or Python, and they allow web servers to dynamically generate web pages in response to user inputs or actions.
The primary function of CGI is to handle data submitted by a user, usually through a web form, process that data, and then generate a page of results that can be viewed in a web browser. This makes CGI a crucial technology for interactive websites where users need to input and submit data, such as search engines, online forms, and e-commerce shopping carts.
When a user fills out a form on a website and submits it, the form data is sent to the web server which then invokes the corresponding CGI script. The CGI script processes the data, perhaps querying a database or performing calculations, and then generates an HTML page as output, which the web server sends back to the user's browser for display.
However, CGI can be less efficient than newer technologies because each request to a CGI script typically spawns a new process on the server, which can be resource-intensive for high-traffic sites. Modern server-side technologies often utilize persistent processes or server-side scripting environments that are more resource-efficient than traditional CGI. Despite this, CGI remains an important concept in web development, especially for those maintaining legacy systems or requiring simple solutions without the overhead of more complex technologies.