Speed Up Your Site: Use a slash on your links

By Daniel Scocco

When a server opens a link in the form of “http://www.domain.com/about” it will need to figure what kind of file or webpage is contained on that address, wasting time on the process. If instead of using that link you include a slash (“/”) at the end like “http://www.domain.com/about/” the web server will already know that the link points to a directory, reducing the time to load the page.

The improvement on the loading time of links ending with a slash will not be astronomical, but when it comes to speeding up a website every small bit helps!

Speed Up Your Site Series:

  1. Optimize Images
  2. Image Formats
  3. Optimze Your CSS
  4. Use a Slash on Your Links
  5. Use the Height and Width Tags
  6. Reduce the HTTP Requests
Monetize Your Site




Share

61 Responses to “Speed Up Your Site: Use a slash on your links”

  • Manta SEO Solutions

    Daniel, it is also useful to add the “/” in .htaccess files when doing 301 redirects

  • Daniel

    Manta, absolutely, thanks for complementing the tip!

  • Alex

    I had no idea that a simple ‘/’ speeds up server respons. Thanks for the tip!

  • Ramanathan

    As Alex said, I had no idea about it as well. Small but great tip. Thanks.

  • Fanatyk

    I didn`t know that – thx 🙂

  • Tassos Bassoukos

    It actually depends on the backend. If you are using apache and the URL is mapped to a file, a 404 will get served. Some systems that do URL rewriting – such as most PHP CMSs – may get confused. And it only works on URLs of actual folders/

  • Daniel

    Tassos, that is right, the “/” should be used with directory pages. It appeared intuitive to me, but its better to clarify.

    Do not use the “/” on file pages like domain.com/index.html/, this will not work.

  • maht

    > When a server opens a link in the form of “http://www.domain.com/about” it will need to figure what kind of file or webpage is contained on that address, wasting time and bandwidth on the process.

    How does this save bandwidth ?

    if anything, it reduces it by 1 byte

  • Ashish Mohta

    I am little biased on that and agree with maht.It doesn’t matter as google or any bot knows what is a page and what is a directory.

  • James

    Sounds great, but how do we know it’s true? Do you have any actual metrics on this? How much “time and bandwidth” is spent when a server has to “figure out what kind of file or webpage” a url points to? If the request has already been passed in, the “figuring out” would be all server-side, and shouldn’t require any additional bandwidth, for example. Details! Thanks.

  • Ashish Mohta

    You have a point there James.It might rather work where you have actual directories.

  • Daniel

    maht and james, the bandwidth part is minimal I agree with you both, so I removed it from the original post. Regarding server response times though, you need to think that even if the improvement is very small it will be multiplied by the number of clients requesting the links, and this can be on the range of 100’s per minute for popular sites. And even if the operation is “server-side” it will need to be processed before the page is served to the client.

  • rick

    It’s not so much that this technique is faster, but it saves you from doing another request. If going to /about will just redirect you to /about/, then why not link to it directly?

  • maht

    to go on further

    You should use slashes because otherwise they are the incorrect uri.

    even
    http://www.dailyblogs.com
    is an invalid uri

    if you really care about saving (insignificant) time during uri->filename translation on directories use

    http://www.dailyblogs.com/index.html

    or whatever your default index page is

    tbh the time difference must be 2 orders of magnitude smaller than the rest of the process

  • Srijith

    How does this save bandwidth ?

    Apache does a ‘stat’ for ‘about’ and on realising that it is a dir, send back a HTTP 301 Moved Permanently with pointer to ‘about/’. The browser then asks for ‘/about/’. So, yes it does save bandwidth.

  • Amanda

    the problem with slash links.. is if you pick it up in wordpress you have a hard time installing subdirectory programs with them.

  • Joe

    This is not necessarily designed to reduce bandwidth; however, it may reduce latency and possibly (on a grand scale) server load.

    When a web browser goes to a link, the Web server controls how and where it’s redirected. In most cases when someone is directed to a the root of a directory without a trailing slash, then the web server performs a brief lookup of any subdirectories and performs a 301 redirect to the browser. This process can take from 1/4 of a second, to even 2 seconds depending on your server.

  • Ashish Mohta

    Thanks for the clarification guys.Didn’t knew apache is doing it internally

  • Jack

    Really interesting stuff. Thank you the insight, everyone.

  • Bes Z

    Thanks for sharing Daniel. I had always thought about using a trailing slash, but was not sure of the exact benefits. If a site is getting a 1000 people to click on 5 links every minute, a site owner should do everything to make sure there is no or minimum lag for any of the users.

    Also, saving even 1 byte of bandwidth for each request is good, as 1 byte of bandwidth saved for a thousand people clicking on hundreds of links everyday means you are optimizing your site and reducing server load. Unless you are on a platform like Blogspot, you need all the juice you can get to make sure things run smoothly and efficiently.

  • maht

    lol, I take it all back

    Apache and IIS both issue 301 headers with a / added

    Which added around 500 bytes to the conversation and an extra round trip.

    I should have got Wireshark out *before* my first post 🙂

  • engtech

    I had an inkling but I had never thought about it before.

    Thanks Daniel.

  • engtech

    (I left a comment without self-promotion!!!)

    Another reason to always be exact with URLs (other than time savings and bandwidth) is for when the URL gets saved to a social bookmarking site. They can be *really* dumb when it comes to not checking to see what the real URL should be.

    I wrote an article about it here:
    http://engtech.wordpress.com/2007/02/28/how-to-save-urls/

  • jamjammo

    In a real world, every-day-web-development-environment, I feel that this is geared towards more consistency and uniformity. True, web server issues are a matter than can not be ignored, but for the average web site owner/developer, a millisecond or two will not be noticed. There is so much to consider when shaving a few seconds off a sites loading time: image optimization, serving a large JS file, many MySQL requests, etc. etc.
    I recall the task a few years ago of optimizing ALL the GIF images from my site, redoing them as PNG, re-FTPing them back to the site, and rewriting the original pages to request the new PNG file instead of the GIF, and man o man, my pages loaded about 2-3 seconds faster.

    I’m not saying that using a slash in your links isn’t worth it – it IS. I’m just saying I use this method as more of a coding convention.

    Like when I found out that www. is deprecated. http://no-www.org/

  • Daniel

    jamjammo, the no-www discussion is another interesting one hehe! I apply it in some of my sites, but most of people are so used to typing www. that it will be difficult to change it in the short term.

  • jamjammo

    >>most of people are so used to typing www

    Actually, that ONLY people I’ve ever witnessed typing in www are the non-geeks that I know. hahaha.
    I once showed a friend how, instead of always clicking in the address bar, just hit: Alt + D, which focuses the cursor in the address bar. man o man was he impressed!
    He has now learned more keyboard commands to STOP using his mouse, unless he has to.

  • Julian

    There’s no reason for not using www. URLs just look better with it and it gives more structure to websites.

  • jamjammo

    (quote from http://no-www.org/)

    By default, all popular Web browsers assume the HTTP protocol. In doing so, the software prepends the ‘http://’ onto the requested URL and automatically connect to the HTTP server on port 80. Why then do many servers require their websites to communicate through the www subdomain? Mail servers do not require you to send emails to recipient@mail.domain.com. Likewise, web servers should allow access to their pages though the main domain unless a particular subdomain is required.

    Succinctly, use of the www subdomain is redundant and time consuming to communicate. The internet, media, and society are all better off without it.

  • Manta SEO Solutions

    I think we’ve wandered off the topic a little, but allow me to share this quickly.

    I prefer the reversed of the no-www ( I like my domain with the www’s). Fix any “Canonical issues” with your domain name, so that whether it is typed with a www or not, you always get the URL displayed as http://www.domain.com. You can also apply 301 rewrite rules to show URL’s such as http://www.domain.com/foldername/index.html to display like this : http://www.domain.com/foldername/.

    i’ve used the following in my .htaccess file to achieve the rewrite as shown above:
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]*/)*index\.php? [NC]
    RewriteRule ^(([^/]*/)*)index\.php?$ http://www.domain.com/$1 [R=301,L]

    For more on canonical issues, see http://www.mattcutts.com/blog/seo-advice-url-canonicalization/ and also at the bottom of http://www.seomoz.org/article/bg4

  • Rene

    Some benchmarks are in order, coz i don’t think a directory/file distinction will be noticably faster..

    I can perfectly imagine such data residing in RAM, meaning the distinction is made in nano-seconds..

  • Piyal

    very good tip

  • Eli

    Must automatically do it or something, I just checked all three of my WordPress installations and all the permalinks end in /, which is the way I like it anyway! 😀

    Good tip anyway! 🙂

  • Thilak

    After reading all comments which follow up. I think the debate is not about bandwidth, it all about pageload speed. Visitors always want the page to load as quick as possible.

  • Zander

    Very useful, cheers for pointing this out.

  • Basketer

    I am ussing a blogger platform. Please help me through the procedure for changing the link since I cant find any option related to that in blogger.

    Basketer/

  • Surfer

    Great Tips Yo !!
    Keep it going if anyone has any suggestion on
    on my site please comment on it.

    thanx

  • Andrei Ancuta

    I have a dillema, how does google reacts if i add a slash at the end of my links because don’t want to lose my rankings.

  • Daniel

    Google does not care.

  • WebProffy

    Hi, Daniel!
    Can you help me… I have links as http://www.site.com/about
    And I want my links look like as this: http://www.site.ru/about/ (with LAST slash)… For 301 redirect I use recommended plugin “enforce-www-preference”… What can I do to have links with LAST slash???

    Help me, PLEASE!!!
    Thx!

  • WebProffy

    Ohh… sorry… http://www.site.COM everywhere in my previous post… Sor… (not post this post as a comment – it’s correction of my prev…)

  • WebProffy

    Hi, Daniel!
    Can you help me… I have links as “http://www.site.com/about”
    And I want my links look like this: “http://www.site.com/about/” (with LAST slash)… For 301 redirect I use recommended plugin “enforce-www-preference”… What can I do to have links with LAST slash???

    Help me, PLEASE!!!
    Thx!

  • Andrew David

    You must use mod_rewrite from htacces file (it is a file like robots.txt), it isn’t very complicated.

  • delpasget

    eltvarcao

  • darraccn

    daracelou

  • webhosting

    @maht,

    its not about saving traffic iets about winning load speed of your site.
    server has les calculations sow result is faster

  • johny

    Thanks for the info. I always use slash for any url. Anyway, I bookmark on some social bookmarking websites, but they cannot display the slash at the end of url. So I want to redirect the page with non-slash-end url to normal url that contain slash at the end.
    How can I do for my website ?

    Thank you in advance …….

  • morton benson crack

    morton benson crack morton benson crack [link=http://oneway.si/store/PDF/docs/laxsitsed.html]morton benson crack[/link] morton benson crack morton benson crack [link=http://oneway.si/store/PDF/docs/laxsitsed.html]morton benson crack[/link]

  • Bang Kritikus

    Thanks this is new information for me

  • Smackitta

    i dindn’t know it !! 🙂 many thanks 🙂 i’ll try it for all my links

  • Keith Davis

    Wow – never knew that.
    Easy to do so I’ll give it a try on all my future links.

Comments are closed.