Forum Moderators: phranque

Message Too Old, No Replies

adding the backslash saves an extra hit on the server?

         

Makaveli2007

10:08 am on Oct 19, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



This isn't really important, but I'm just curious, because I've heard it:

If one calls folders / paths of the website www website com/folder/ ....instead of www website com/folder....does that save an extra hit on the server? or not?

I assume it doesn't really matter a lot, but I might want to go with www website com/folder/ anyway, because that's what will be displayed..and well, it's good form (because the path in the source code and the actual path will be the same), but other than that barely matters?

thanks!

g1smd

11:56 am on Oct 19, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The correct operation for the server, on receiving a request for /folder and where that name matches a real physical folder on the server, is to send a 301 redirect to /folder/ which is an extra step.

So, for folders, always append the trailing / in your links.

jdMorgan

1:02 pm on Oct 19, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Apache mod_dir [httpd.apache.org] Summary:

A "trailing slash" redirect is issued when the server receives a request for a URL http://servername/foo/dirname where dirname is a directory. Directories require a trailing slash, so mod_dir issues a redirect to http://servername/foo/dirname/.
(Emphasis added)

If you fail to link properly to directories by including the trailing slash, then every client request for that slashless directory URL will result in two HTTP request/response transactions between the client and the server. The first client request will result in a server redirect response, providing the correct address including the trailing slash. Then upon receipt of the second client request, now including the trailing slash on the URL, the server will return the desired content. This is slow, inefficient, and wasteful.

This is easy enough to verify... The Live HTTP Headers add-on for Firefox/Mozilla browsers will show these transactions quite plainly.

Jim