Server Side Includes (SSI)
Server side includes have saved me hundreds of hours, assured that my site is accurate throughout, and created clean web pages with much less code. How do they work?
First take a look at the content of your pages and identify which elements are repeated on every page. If the same group of links, or contact information is included at the bottom of 100 web pages then wouldn't it be a time saver to create a single file called "bottom", which contains the text and links. Next you would remove the links and contact information from the 100 html documents and substitute a single line of code that refers to the bottom file.
That may seem like more work than just writing each page from top to bottom, and it is... until you have to change something. Let's pretend you have 100 products pages and you need to change the refund policy which appears at the bottom of every page. Here are the steps involved in changing the pages WITHOUT ssi
1. download all 100 pages
2. open each file
3. find the old refund policy and replace it with the new
4. save each file
5. upload all 100 pages.
Compare that to the steps involved in changing a site with SSI
1. download the file called "refund"
2. change the contents of the file
3. save it and load it onto the web
Because I am using server side includes I can change 100 files by modifying only one file.
If this concept is sounding familiar, that's because it is. Cascading style sheets allow you to link to an external CSS file and control the look of 100 documents. Server side includes allow you to use the linking principle to control the content of 100 pages. The principle of controlling a collection of documents from a single file is employed in both server side includes and cascading style sheets. As site become large, using these technologies makes it much easier to maintain and modify your site.
Have you ever visited a Web page which displayed today's date and time, or the date a file was last modified? Been scratching your head over how they can do that? Well SSI code is the answer. The server is constantly keeping track of the date and time and would be happy to display it on your page, if you just use the SSI code correctly. The server also keeps track of the date you last uploaded a file onto the Web. If you have materials that are time sensitive, placing the date last modified information can be invaluable.
Finally we will use SSI code to create a simple counter. This code will cause
the server to execute a simple UNIX script which increases a file by "1" every
time your page is hit. The SSI also displays the contents of this file on
your web page.