Introduced
I have not experienced CGI's very fiery years, has never had a chance to learn about the development of CGI web apps, until recently, after listening to a roommate who despised the idea that QQ was still using CGI to develop its own application, the mind gave birth to a thought about CGI, and after some study and research, Also clear up some of the issues, and share with you.
Introduction to CGI
Wikipedia has a more detailed description of the CGI, based on its own understanding summarized below.
First, the role of CGI in processing requests in a Web server is as follows:
As pictured above, CGI plays the role of a protocol that enters output between a Web server and a particular language interpreter, each request from a user, the Web server evokes a command line for a particular language interpreter (for example, Python), and CGI acts as a convention to get the request data from the Web server ( such as url,post data), optionally entered as command-line arguments into the interpreter's command line (standard input), the interpreter constructs a specific HTML as the standard output based on the input, and then the CGI makes additional processing of the output, such as adding a specific header (MimeType, Cookies, etc.) back to the Web server, which is then returned to the user (the Web server may do additional processing).
This is a complete process.
The disadvantages of CGI
CGI as a standard protocol, a variety of mainstream Web servers are supported, such as Apache,iis, then from the above processing process we will find several major drawbacks:
For each request, a process that creates a new interpreter is required, and process creation is usually more expensive (expensive)
Also, for scripting languages, the interpreter needs a certain amount of time to interpret the resulting HTML
A greater chance of code injection, because it is more likely to be injected in a CGI script by manual processing of HTML (depending more on the programmer itself)