You Need Ssi Right Now!

Jan 13
22:00

2002

Bob McElwain

Bob McElwain

  • Share this article on Facebook
  • Share this article on Twitter
  • Share this article on Linkedin

I learned of SSI (Server Side Includes) long before I builtmy current site. Since it seemed the only way to go, I checkedit out once again for the new site to be.

mediaimage

What SSI amounts to is creating a new page for any elementscommon to all pages on your site. Then ask the server toinclude these pages whenever main pages are requested.

For example,You Need Ssi Right Now! Articles build a regular HTML page containing all thecontent, including graphics, as is often used in the left columnof a page as the basis of navigation. Then, instead of addingthis content to each page, simply include the file. And hey,it's super. If you need to make a change, you make it onlyonce, instead of on every page on your site.

SSI Slows Page Downloads?

What prevented me initially from using SSI were notes I readregards increasing page download time. Each page using includedfiles needs to parsed (read) by the server to find any files tobe included. Being an absolute fanatic about minimizing pagedownload speed, I passed. Bad mistake.

Updating Multiple Pages Chews Up Time

Six month later, changing a single menu item was takinghours. I decided to ignore the page download time and go.But I ran into another snag. Pages with includes need theSHTML extension, else the server won't parse them. (An Sin front of HTML.)

Switching From HTML to SHTML Busts Links

Nuts. I already had lots of incoming links. Since I didn'twant to bust them by changing file names, I passed once again.

I had heard people speak of ways in which a server in somecases could be instructed to treat HTML pages as SHTML pages.But I didn't check it out. Another bad mistake.

The Perfect Solution

Many months later I ran across the following code. Addthese lines to the top of your .htaccess file, and all existingHTML files will be parsed just as if they had the .SHTMLextension. Neat. No changes in file names, which meansno busted incoming links.

Options Includes AddType text/html .html AddHandler server-parsed .html

.htaccess is a hidden file in the root directory on yourserver. It is helpful in doing many things, and can be locatedelsewhere as needed, but for now let's focus on the above.

In WS_FTP, when you type -al into the blank field to theright, this file name will become visible. The best plan is todownload the file, add the above code, then upload and overwritethe original. (The reason for downloading first is to becertain you hold whatever the file may already contain.)

Creating Files

What I did next was create a file, yleftnav.html, containingall the content in the left column of a page. Then on eachpage, I replaced the content in that column with the following.

Given the three lines above in the .htaccess file, each .HTMLfile is parsed for the include command. When found, the contentof the file is included in the page at that point. You can seethe results by viewing the source for one of my pages. And youcan view the file included with ...

The display of this page will be distorted, but it works finewhen constrained by the first cell/column on each site page.

I'm also using ybotnav.html for the text links and contactinfo at the bottom of each page. Anything repeated on most orall pages can be handled in this way.

Finally Getting To It

I continued to avoid the chore for many months. And whenI did get to it, hours disappeared quickly, for by then I had morepages.

But hey, I do love it. And there's good news besides.Those notes regards slowing page downloads (they're stillaround), appear to have applied in an earlier time when serverswere slower. I haven't detected any increase in the downloadtime for the pages on my site.

Get to this right now, before your site grows even larger.Whatever time it takes will be saved many times over on futurechanges required.

Test First

Before getting carried away, be sure to test to see thatwhatever code you choose works properly on your host server. Ifit does not, and your host can't help you, then you may be stuckwith renaming page name extensions to .SHTML. Which also meanschanging links internal to your site. And losing any links toyour site. (Even this option isn't available on all hosts.)

An Alternative

Here is another include command I am not using on my site.It assumes all files to be included are in /includes/, asubdirectory within the directory containing your pages.

@@START_COMMENT#include virtual="includes/includefile.html"@@END_COMMENT

Since my site layout is simple, and includes only threesubdirectories for pages, I simply uploaded the files to beincluded to these three directories, and to the root directory.For me, this is a great solution for it takes only minutes toupload four copies. You might do better, however, with theabove.

Further Resources

What triggered me into action was Jennifer Johnson'sarticle, "How To Avoid Website Growing Pains." She's beentrying to talk me into using SSI for years. I should havelistened to her and got to it sooner. (And so should you!)Here's a link to her article.

Here's a page from Webopedia given a search on SSI. Lotsof great info referenced here. Follow the link to Yahoo fora couple more. As a reminder, that bit about slowing downloadspeed is included in one of the referenced articles. I'd ignorethis, for I found no degradation at all.

Wrapping Up

I should have done this years ago. Do it now. Or you'll besaying the same thing in a year or so. Honest, you will!

Article "tagged" as:

Categories: