|
jeepless -> RE: Edit Hyperlink... Slash or no slash... (12/12/2004 12:23:33)
|
Getting back to the original question..... I remember a thread about this subject on another board, Webmaster World, and it was suggested that it's ALWAYS a good practice to include a slash after a hyperlink if it's referring to a subfolder or a subdirectory under the root directory (eg. http://www.yoursite.com/subfolder/). I don't recall the technical details, but it had to do with cutting down the amount of communication involved between the browser and the server to pull up the correct page. In simple terms this is what happens... Without using a trailing slash: the browser opens a connection and calls the server with the URL http://www.yoursite.com/subfolder (notice the missing slash), but the server doesn't know if that URL refers to a FILE or a SUBFOLDER. So the server first goes looking for a FILE called "subfolder". When it doesn't find it, the server then responds to the browser, "Did you really mean the SUBDIRECTORY called "subfolder?" (a corrected URL) and the server then closes the connection. The browser then opens a new connection with the server and makes a second request saying, "Yes, I mean the SUBDIRECTORY called "subfolder" (the corrected URL), and the server then responds by sending the default page for that subfolder and again closes the connection. The result is that we had to open TWO connections to download the default page, and consequently forced the server/browser to make TWO round trips for that one page. That's generally considered to be "unnecessarily taxing the server's performance" by the web gurus. With the trailing slash: the browser opens a connection and calls the server with the URL http://www.yoursite.com/subfolder/ (notice the trailing slash) and the server immediately knows that the browser is referring to a SUBDIRECTORY called "subfolder". The server then responds by sending the default page for that subfolder and closes the connection. One connection, one round trip! In reality, forcing the server/browser communication into making two round trips to call up one page is virtually minimal and you would probably never notice a difference in speed. But with a very slow dial-up connection it might be noticeable. Still it's generally considered unnecessary and bad practice according to web gurus. It should also be noted that using a trailing slash at the end of a URL that specifies the ROOT directory is unnecessary since the server and browser implicitly understand that a base URL (http://www.yoursite.com) always refers to a root directory and not a file. The server doesn't have to consult with the browser about what it really wants so the server sends the default page in the first connection. Therefore, trailing slashes on base URL's are not needed. As stated on the "A List Apart" website: quote:
The rule is "every URL that names a subdirectory should end with a trailing slash". Why should we bother? Because: 1. We’re doing ourselves a favor, as this is the correct way to do things. 2. We’re doing our server a favor, as this means less disk access. 3. And most importantly, we’re doing our visitors a favor, because they’re no longer losing a few seconds while our server tries to first find a file and then a directory. And in this industry, you and I both know that a few seconds is a long, long time. Hope that helps...
|
|
|
|