My Stuff

Always end a URL with a slash '/'

This is really embarrassing but you always learn something new!

You should always enter the trailing ‘/’ slash at the end of a web URL. Why because it is faster.

Two reason. First if you enter a wrong URL it doubles the number of requests it takes to fetch the web page.

For example if you enter:

http://azcentral.com
And you look at the data that is sent to the browser you will see that this request returns
HTTP/1.1 302 Found
Location: http://www.azcentral.com/
Of course your browser is smart enough to say “the dumb user entered the wrong web address” but I will correct it and send the correct URL which the browser got from the initial request and is:
http://www.azcentral.com/
back to the website. But the key is it took two commands to request the web page when t he page could have been fetched with one command.

Now the second reason it is faster to type:

http://www.azcentral.com/foo/
with the slash ‘/’ at the end instead of
http://www.azcentral.com/foo
with out the slash ‘/’ at the end is that if you type first instance with the ending slash ‘/’, the server doen’nt have to figure out if ‘foo/’ is a file or a subdirectory. It knows that ‘foo/’ is a subdirectory because of the ending slash ‘/’.

Now if you type the 2nd URL which doesn’t end with a slash ‘/’ the server will have to figure out if ‘foo’ is a file or directory. This doesn’t take much time, but when your creating web pages it will save a little time for the server.

Also you can use this program or web page to test the logic. It will show you what the server returns when you type in

http://azcentral.com
v.s.
http://www.azcentral.com
 

Other Stuff