• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

absolute vs relative urls

Collapse
X
  •  
  • Filter
  • Time
  • Show
Clear All
new posts

    absolute vs relative urls

    i remember reading about this some time ago but neither memory nor google seem able to regurgitate.

    is there any difference in performance between specifying urls absolutely

    (eg http://www.bbc.co.uk/mynews/news.php)

    and specifying them relatively

    (eg news.php)

    when creating the link within the same directory as the target file?

    #2
    Originally posted by scotspine View Post
    i remember reading about this some time ago but neither memory nor google seem able to regurgitate.

    is there any difference in performance between specifying urls absolutely

    (eg http://www.bbc.co.uk/mynews/news.php)

    and specifying them relatively

    (eg news.php)

    when creating the link within the same directory as the target file?
    I always thought that relative urls were more efficient but my googling suggests not? Smaller file sizes, less bandwith is all I could come up with so far I'm afraid.
    +50 Xeno Geek Points
    Come back Toolpusher, scotspine, Voodooflux. Pogle
    As for the rest of you - DILLIGAF

    Purveyor of fine quality smut since 2005

    CUK Olympic University Challenge Champions 2010/2012

    Comment


      #3
      It depends what you mean by "performance". As Zippy says, you'll save a few bytes going over the wire. The browser isn't going to slow to a crawl when you click on either of them. Search engines aren't going to bother about the difference. JavaScript performance is unlikely to be affected for any scenario I can think of. If you are building static pages and then want to move them to a subdomain or a different domain altogether you'll have a bit of search-and-replace work to do.

      Comment


        #4
        the reason for asking was that iirc the browser reconstructs the absolute url, if it has been given a relative url, before submitting the request to the server but i'm not sure that i recall that correctly.

        Comment


          #5
          Originally posted by scotspine View Post
          the reason for asking was that iirc the browser reconstructs the absolute url.
          You make it sound like that'd be complicated. It's a simple string operation. The client machine could probably do it several million times over in the time it takes the server to respond.
          Will work inside IR35. Or for food.

          Comment


            #6
            Originally posted by scotspine View Post
            the reason for asking was that iirc the browser reconstructs the absolute url, if it has been given a relative url, before submitting the request to the server but i'm not sure that i recall that correctly.
            It has to to determine which server to submit the request to. Remember, it's all just HTTP. In fact, it has to decompose the absolute URL as well, as it has to make a socket connection to the host, then request the absolute path and, for HTTP 1.1, include the Host header:

            Code:
            GET /foo/bar/tubgirl.jpg HTTP/1.1
            Host: www.example.com

            Comment

            Working...
            X