• Home
  • /
  • Blog
  • /
  • Speed Up Your Site: Use a slash on your links

background image

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


You may also like

Hostinger Review

Hostinger Review

Best Web Hosting Services

Best Web Hosting Services

SiteGround Review

SiteGround Review

About the author 


Daniel Scocco is a programmer and entrepreneur located in São Paulo, Brazil. His first company, Online Profits, builds and manages websites in different niches. His second company, Kubic, specializes in developing mobile apps for the iOS and Android platforms.

  1. 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.

  2. 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! 🙂

  3. 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..

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

  5. >>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.

  6. 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.

  7. 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.

  8. (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:

  9. 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 🙂

  10. 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.

  11. 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.

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

  13. 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.

  14. 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?

  15. 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.

  16. 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.

  17. > 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

  18. 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.

  19. 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/

Comments are closed.

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}