Internet Business Blog

Tuesday, July 05, 2005

Use SSI to save Time Maintaining your Website

Last week I logged onto my stats at StatCounter to find that they were flooded with information about a website that wasn't owned by me.

Upon further investigation I found to my annoyance that someone had copied chunks of my website, including my StatCounter Javascript code and my unique ID on to their web page and then advertised it on a traffic exchange or something similar.

This meant that I no longer had access to accurate stats about my own website as they were skewed with stats on this other persons website.

I sent a polite email to the webmaster of the aforementioned site asking him if he could remove the offending code. After a few days with no reply, I posted a question on the support board at the StatCounter site and got an immediate response from someone saying that I needed to re-generate my javascript code to get a new ID, then I should turn on a security option to prevent anyone swiping the code in the future.

This part was easy. The problem was that I then had to update approximately 70 web pages with the new javascript code and upload them to web server. It took me about an hour and a half to do this, which isn't too bad, but it was an hour and a half that could have been spent doing something more worthwhile.

At this point I wanted to make sure that this never happened again, so I looked into using SSI (Server Side Includes).

One of the benefits of SSI is that it allows you to include other HTML files in your webpages. For example, if I have a website with 100 pages and each page uses the same header graphic and menu, the same footer and the same statistics code I can create three new files e.g. header.html, footer.html and stats.html. These files just contain the fragments of html code or javascript.

I then just have to include them in the correct places in my web pages.

This saves me from
a) Cutting and pasting all that HTML or javascript code into every single web page and
b) Making changes to every single web page every time I want to update my menu or change the copyright dates on my footer etc

I really should have looked into this when I first started writing my web pages, but at that time I was just so desperate to get it finished that I didn't give it any thought.

If you want to know more of the technical details about how to enable SSI and how to use it see the Apache SSI Tutorial

One good thing to note is that using SSI won't affect your search engine rank, because the search engine spiders will see the full html source after everything has been included. In fact you can't even tell that SSI includes have been used if you go to my website and do View->Source, despite the fact that I have SSI includes for my header, footer, Google AdSense blocks, search box and Statistics.

SSI includes can even help your search engine rankings. For example you can use includes to display fresh content on all your pages and change this regularly to give the search engine robots new food to chomp on.

Funnily enough, when I logged into my email today, what did I find? An email from the webmaster who had copied my Javascript code telling me that he had removed it and apologising for the delay in doing so. Normally this would annoy me, since I have gone through the pain of changing everything, but this time I'm feeling quite happy - this guy has done me a huge favour!


Post a Comment

<< Home