start page | rating of books | rating of authors | reviews | copyrights

Book HomeWeb Design in a NutshellSearch this book

Chapter 18. 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.)

18.1. 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.

18.1.1. 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 environment.

  • It isn't browser-dependent like JavaScript, so it works 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 functions.

18.1.2. 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.

  • SSI is not as robust a solution for dynamic page generation as other scripting methods such as ASP or PHP.

18.1.3. 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 programmer to design the back-end for more advanced SSI solutions.



Library Navigation Links

Copyright © 2002 O'Reilly & Associates. All rights reserved.