Updated November 2025; see History
FastCGI is an optimized variation of the normal CGI protocol, which differs primarily in that the application server instances persist across many requests, rather than having to be launched and terminated for each request. FastCGI thus vastly reduces the overhead of servicing web requests, particularly for relatively large/complex application servers (like A-Shell).
FastCGI is widely available on common web servers such as Apache and IIS, but almost certainly requires some configuration to enable. As of this writing, is has only been tested with Apache 2.4.
To enable support for FastCGI protocol in A-Shell, change the -cgi command line switch to -cgifast. A-Shell will then determine whether the server is using FastCGI or normal CGI protocol, and will act accordingly—i.e. support either protocol.
Existing A-Shell CGI applications require a minor modification after which they can support either mode as well, without having to be aware of the difference. Since the main objective of FastCGI is to avoid the need to launch a new instance of the application server for each request, you need to introduce a loop into your application so that after servicing a request, instead of exiting, it loops back to wait for another request. In other words, you must convert this:
<process request>
<send response>
end
to this:
do
xcall CGIUTL, CGIOP_GETREQ, status
if status < 0 exit
<process request>
<send response>
loop
end
The CGIUTL opcode CGIOP_GETREQ waits until the request has been received and is ready to process in the normal way. For the first request after the instance has been launched, it will return immediately (be essentially a NOP). For subsequent requests, it waits until another client submits a request, or perhaps the server shuts us down. In the case of normal CGI mode, the second request will return -1, telling the app to shut down, as it would normally do for CGI.
Note that FastCGI does not eliminate the standard CGI problem of having to reestablish the client context for each request. Consecutive requests received by the server instance of your application can easily be from different clients, so you need to design some means of identifying the client and saving/restoring the context of that client's browser session—using parameters passed with each request or cookies, saved context files on the server, etc.
History
2025 November, A-Shell 7.0.1781 (Linux): Beginning with A-Shell 7.0.1781 of November 2025, FastCGI supports on-demand linking of libfcgi.so rather than static linking. This reduces the size of the ashell executable for the vast majority of cases not using FastCGI, as well as providing more flexibility in the field to choose among FastCGI implementations.
There are two tests you can use to determine whether and how FastCGI is supported:
a)You can detect whether the library is static-linked (embedded) in the ashell executable with the following Linux command:
$ nm ashell | FCGI
If it lists several matches, then the library was static-linked.
b) For then non-static-linked case, you can test the ability to dynamically load the libfcgi.so library using the test program FCGITEST.BP and its companion FCTITEST.CMD from the 908062 directory in the EXLIB repository. Read the notes at the top of the source for instructions on setting up and running the test.