SSI: The WebMaster's Secret Weapon
by Jim Walker, Internetter.com Interactive

If you are an accomplished WebMaster or otherwise experienced user, you've probably heard about Server Side Includes. You might have even thought, "Sounds too difficult to setup...right?" Well, if you've never heard of Server Side Includes before, here's a definition from an excellent book by Manuel "Alberto" Ricart, called, "Apache Server Survival Guide," E-mail: aricart@accesslink.com. I highly recommend this book for all Web Server aficionados.

"Server Side Includes (SSI), also known as Server Parsed HTML (SPML), provides a convenient way of performing server-side processing on an HTML file before it is sent to the client. SSI provides a set of dynamic features, such as including the current time or the last modification date of the HTML file without developing a CGI/PERL program that performs this function. SSI can be considered as a server-side scripting language."

If this description sounds a too bit technical for you, I'll paraphrase. Server Side Includes are the simplest, easiest way to generate dynamic web sites without any technical expertise of any sort.

Server Side Includes use simple HTML style commands you can add to your web page to either import a text page or run a CGI/PERL script before the page is served to the client (viewer of the page). If you can imagine a web page with an HTML table in the center, composed of four cells, each separate cell presenting the client with a different web page, or an executed CGI/PERL script, you can begin to see the power of the Server Side Include.

Before we get into how to use SSIs in your pages, here are a few disclaimers. If you have access to an Apache style server, first ask your administrator if SSIs are enabled. They are disabled by default. Due to the differences in server configurations, the exact commands described here may not work on your server. Contact your Web Server administrator for the exact commands used on your server.

With that out of the way, here are actual HTML page samples incorporating SSI:

filename: ssihtml.shtml
<HTML>
<HEAD>
<TITLE>Server Side Includes HTML Sample</TITLE>
</HEAD>

Example of a server side include inserting a block of text onto a Web
page:

<!--#include virtual="directory/insertpage1.html"-->

</BODY>
</HTML>

filename: ssicgi.html

<HTML>
<HEAD><
TITLE>Server Side Includes CGI Sample</TITLE>
</HEAD>
<BODY>

Example of a server side include inserted a script on a Web page:

<!--#exec cmd="cgi/myscript.cgi"-->

</BODY>
</HTML>

That is all there is to it. The first sample, ssihtml.shtml, prints the first line of text ("Example of a...") and adds the text or HTML in the insertpage1.html file to the page (ssihtml.html). This is completely transparent to the client.

The second sample prints the first line of text ("Example of a..."), then embeds whatever process executed from the myscript.cgi script to the page. Again, this is transparent to the client.

Server Side Includes can be tremendous time savers in large Web project. Consider the amount of time saved if every page on your 1000 page Web Site had the same footer and you needed to modify a graphic in that footer. Normally, you would have to go into each page to the do the modification (that is, if you are not using an elaborate HTML publishing program of course). Since you are now an expert in the use of SSI, you simply have to change one html file and all of the pages on your site are instantaneously changed for all to view (miraculous isn't it).

So you ask, "Why aren't more people using SSIs if it is so easy to set up?" Well, there are some caveats.

1. First, many web servers require you to name your pages with the .shtml extension. This causes great heartache among some purists.

2. There are some security issues involved in the exec cmd call, so some servers have script execution turned off.

3. Extensive use of SSIs can effect server performance.

4. Most folks just haven't tried them.

There are additional advantages to using SSIs. SSIs allow some fairly advanced functions, such as, browser detection, CGI environment variables display and more. For Apache Servers, there is even an Extended SSI module (XSSI). This SSI enhancement allows for if-then-else statements, user-defined variables and other commands similar to those used in CGI/PERL scripts.

If you are interested in more information regarding SSIs, the following Sites provide some interesting reading:

With a little imagination, Server Side Includes give you the capability to create dynamic pages in little or no time, without any programming skills. Adding this weapon to your arsenal of design tricks may be all that's needed to beat out your competition in your next big project bid.


Jim Walker is the President of Internetter.com Interactive. His company is dedicated to providing the best possible design and Web hosting service on the planet. For dependability, professionalism and some of the highest Web Server speeds in the World today, see Internetter.com Interactive for more details.

Return to Internetter.com

Got Web Site?
Try www.tvcnet.com. Awesome service and great rates.
We've been using them for years.