251
Server Side
Includes
Web Design in a Nutshell, eMatter Edition
Chapter 13Server Side Includes
CHAPTER 13
Server Side Includes
In layperson’s terms, Server Side Includes (SSI) are special placeholders in an
HTML document that the server will replace 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
toparsethe 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 gener-
ated 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:
- Placing elements that you use over and over again. If you have an element
that appears on every page of your site, such as a complex navigational
header, you can place a single SSI command that just sources it in instead. If
you make changes to the header, such as changing a URL or a graphic, you
only need to make the change once, and it will be updated automatically on
all pages of your site. - Place a constantly changing element on your page with a single line. For
example, if you maintain a homepage that has a message that changes every
day, use a Server Side Include command (and a script on the server) to
replace the message automatically. You never need to touch the source code
for the home page—you just let the server do the work.