What is CGI?
CGI or Common Gateway Interface refers to the standard means used by web servers for interfacing with executable programs that have been set up on the server and which generate pages dynamically. These programs are typically referred to as CGI scripts and they are written in scripting languages and also in programming languages. With the CGI, the web server can pass an internet user’s request onto applications and receive the data to forward again to this user.
How does CGI work?
Whenever a user requests for a web page by clicking on some highlighted word or by typing in a site address, the web server sends the requested web pages. When users fill out forms on web pages and sends these, they must be processed through application programs. The server here passes the data to an application program which processes this data and sends a confirmation message back. This process for sending data to and fro between the server and applications is the Common Gateway Interface or CGI.
So, the CGI program has been designed for accepting and returning information which conforms to CGI specifications. The CGI programs are very commonly used by web servers for interacting dynamically with their users. Another popular way to give dynamic feedback is including scripts which run on user machines and not the web servers. These are Java applets or Java scripts and are collectively called client-side solutions. The CGI, on the other hand, is a server-side solution since processing takes place on web servers.
The only flip side of CGI is that every time any CGI script is run, it initiates a new process and this can slow down the extremely busy websites considerably. Since the CGI script may end up putting a lot of pressure on the web servers the faulty programs or poorly written programs are likely to fall into continuous loops and this exhausts server time. While the browser will time out automatically after a few minutes, the server still runs the program till the system administrator shuts off this faulty script.