views:

795

answers:

3
+1  Q: 

What is CGI mode?

What does it mean when we say an application can run in CGI mode? I was reviewing the features of various CMS systems on cmsmatrix.org and "CGI mode support" was listed as a feature. What are the other "modes" in which a web application can run?

+1  A: 

CGI stands for 'Common Gateway Interface', which is an old architecture for web applications. CGI works by placing the variables from the HTTP request and fork/exec()ing the CGI process. It gained popularity in the early days of web development as it worked well on a unix host. Perl/CGI was a popular architecture in this era and it contributed substantially to the popularity of Perl as a language.

The main claim to fame of CGI is that it doesn't require much plumbing, so it will work with most web servers. The main drawback is that the fork-exec process is slow-ish as the CGI script has to be started (which may involve starting a perl or other interpreter). On Windows, spawning a new process is much slower than unix, so CGI is even more inefficient.

ConcernedOfTunbridgeWells
+1  A: 

CGI is a protocol that is used by web servers to call executable files on the server. Upon receiving a request, it sends the information about the request to the cgi script and returns the result of that script back to the browser.

An alternative to that is fastcgi. This means, that the web server does not contact a script to answer the request, but a process. The communication protocol is still the same, though (hence the name).

soulmerge
+1  A: 

Basically, CGI implies that the webserver will execute an external process, get its result (a generated HTML page, an image, ...) and send it back to the client.

This has major drawbacks because it launchs the external process each time it is needed, so this can be a big overhead.

You have also FastCGI that launch the external process once, and reuses it when needed.

But usually, languages are integrated directly in the webserver. For example, Apache has a mod_perl module to execute perl scripts, instead of executing perl scripts via CGI

chburd