Sunday, 7 September 2008

The hyperlink trailing slash

When creating hyperlinks to a folder resource, always trail with a forward a slash. (slower)

Vs (faster)

Any reqeusts for the URL without a trailing slash will hit the server and a 301 redirect will be returned to the URL with a trailing slash. This is because the server thinks that "test" is a file and tries to locate it. After searching, it realises that the request was actually for a folder called "test"; therefore it's response informs the client of the correct URL (with a trailing slash).

It makes sense to include the trailing slash to speed up your website and reduce the load on the server. It doesn't make that much difference for root domains but it's good practice anyway:


No comments: