Main | Second Post »

01/12/2008

Gripe: Absolute URL versus Relative URL

Ah FrontPage. You made it so easy to create web sites that there are many, **many** web site developers out there who do not know the difference between an absolute URL and a relative URL. I'm not talking about those cases when you need to link somewhere offsite--I'm talking about links to content that reside on your own site. Yes, this first post is a gripe. You would be surprised with how many times I come across this when we're going through a site. I once spent a couple of hours on the phone going over the differences between absolute URLs, relative URLs, and, of course, the server relative URL with a group of developers and I think by the end of the conversation, they were just saying "ok" to get me off the phone. What's wrong with using an absolute URL within your own site to link to your own content? Consider the following HTML for a fictional company's product manuals.


Absolute URL Example

a href="http://our.awesomesite.com/manual/index.html"> Product Manuals

Relative URL Example

a href="manual/index.html"> Product Manuals


Although both work and will result in loading the same page, the first will make troubleshooting problems with the web site a little bit tougher.

Consider the following example: our.awesomesite.com runs across a pair of web servers, serverA.awesomesite.com and serverB.awesomesite.com. A browser making a request for the homepage hits the load-balancer and the load-balancer sends that request off to one of the two real web servers. Now let's say that some of our customers are reporting an "intermittent" problem with one of the two web servers getting the manual. We operations-types fire up a browser and go to http://serverA.awesomesite.com/, (bypassing the load-balancer), and then click the link for the manuals. The trouble hits when we click that link. Due to there being an absolute URL, our browser gets sent back to the our.awesomesite.com address instead of going to the real server. If we experience a 404-Not Found error, we still don't really know which server is generating the error.


I understand that this example may be over-simplistic because since we assumed these were static pages, then we could just go to http://serverA.awesomesite.com/manual/index.html and see if we get an error and repeat the step for serverB. This becomes more annoying when there are dynamically-generated URLs and you have to go to the homepage, login, etc. Obviously, the scope of this article is geared towards web sites developed and running within the enterprise. Sites that are load-balanced because they have to be up. Sites that cost the company serious money when they are down.


Ditto for those base href's that some folks are so fond of. Avoid absolute URLs and base href's if at all possible.

TrackBack

TrackBack URL for this entry:
https://www.typepad.com/services/trackback/6a01156fbc6fe6970c011572287fe3970b

Listed below are links to weblogs that reference Gripe: Absolute URL versus Relative URL:

Comments