Server Side Includes

Contents:

How SSI Is Used
SSI and the Server
Adding SSI Commands to a Document
Using Environment Variables
XSSI
SSI Commands
Include Variables
Time Formats for SSI Output

In layperson's terms, Server Side Includes (SSI) are special placeholders in an HTML document that the server replaces with actual data just before sending the final document to the browser. By the time the document gets to the browser, it looks just like any other HTML page (even if someone happens to "view source"), as though you typed the data into the HTML source by hand.

When the server looks through the file for placeholders (SSI commands), it is said to parse the file. The server then inserts the requested data, which could be anything from the current date and time to other HTML documents to the results of a CGI script. (The complete list of information available via Server Side Includes is listed later in this chapter.)

How SSI Is Used

SSI allows you to create the framework for pages that will be dynamically generated by the server. For the web author, this can be a powerful tool for managing site production and increasing efficiency. The following are just a few examples of the ways SSI can be used:

Obviously, these are just a handful of possibilities, but they demonstrate the sort of tasks well suited for Server Side Includes.

Advantages

Server Side Includes offer the following advantages:

Disadvantages

There are few disadvantages:

Getting the Most Out of SSI

The examples in this chapter illustrate the basic form and function of SSI commands. On their own, Server Side Includes provide some useful, though limited, tools for dynamic page generation. The real power of Server Side Includes comes in the combination of SSI commands with CGI scripts running on the server. The CGI programs do the necessary processing before the information is ready to be placed in the HTML page.

If you focus on front-end web design, you can get started right away using the elements and variables listed in this chapter, but you may need to consult a CGI developer to design the back-end for more advanced SSI solutions.