Quick Perf Tip: Always Add A Trailing Slash

16 Jul 2010

Here’s a quick performance tip for your Friday (or Saturday for those of you across the date line) – when linking to a directory, be sure to add the trailing slash to the directory name, otherwise, it causes a redirect from the server, thus adds a bit of time to your page load!


<a href="http://www.petelepage.com/blog/">Pete's Blog</a>


<a href="http://www.petelepage.com/blog">Pete's Blog</a>

What’s going on?

When the browser makes a web request for a page without the slash, it responds with a 301 redirect response, which then causes the browser to make a second request for almost the exact same page, except it asks for it with the trailing slash! On a client with a slow network connection, that’s going to be really painful! Even if it’s not a slow connection, it is going to add some extra time to your page load!