252 Chapter 13 – Server Side Includes
How SSI Is Used
Web Design in a Nutshell, eMatter Edition
- Show the date and time the page was last updated.
- Allow multiple users to submit content for inclusion on a web page without
giving them access to the HTML source. For example, staff members could
send in weekly updates via email. The server could run a script that turns the
email into a text file, which is then inserted into the web page via an SSI com-
mand. - Serve an appropriate web page based on the browser making the request.
You can even serve documents based on the user’s domain name. (Note: not
all servers can perform conditional functions. This is discussed later in this
chapter.)
Obviously, these are just a handful of possibilities, but they demonstrate the sorts
of tasks Server Side Includes are good for.
Advantages
Server Side Includes offer the following advantages:
- It’s easy to learn the basic SSI syntax and start implementing simple SSI.
- Most servers provide support for SSI or can add it quickly (check with your
server administrator first). - Pages can be dynamically generated, including up-to-the-second information
and content served based on information about the users’ viewing environ-
ment. - It isn’t browser-dependent like JavaScript, so will work for everyone (as long
as it works on your server). - The commands don’t display in the browser, so your methods are invisible to
the user. - It’s less work for the server than processing CGI programs for the same func-
tions.
Disadvantages
There are few disadvantages:
- Parsing a file and adding information requires slightly more work for the
server than serving a straight HTML document. - Enabling Server Side Includes on the server may pose a security risk. Talk to
your server administrator to find out the policy for SSI on your server.
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 provides some useful, although
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.