4

I was told by my hosting provider's technical people that I should be using relative file paths (/home/index.php) instead of absolute paths (http://www.example.com/index.php) to "reduce server load".

His words:

[logs showing that my domain name is a popular 'referrer' for page loads]

This is the vast majority of your hits. Since this is your own website the sole reason this referrer is generating this traffic is because you are using absolute url's in your code rather than relative paths.

Please speak to your web developer and have him change ALL absolute urls in your code to relative paths. This will make your code portable and it will reduce the load. I don't believe this site really needs a [dedicated] server. This is just a case of you driving the traffic to yourself with poor coding practice. Please fix this.

Can someone please explain to me how this makes any sense, if it does? The page in question is a sign-up form, and it uses an absolute-pathed PHP header(Location) to refer traffic once it's passed validation and stored in the database. I can see how relative paths would make my code more portable, if I were to change domain names, but either way it's requesting the same data from the same server.

Thanks so much for the help, I'm really puzzled over this! The tech guy who sent this isn't answering my followups.

  • 2
    Changing absolute paths makes sense only in a file I/O context. `header: location` URLs *have* to be absolute, and if they aren't, the browser *may* be nice enough to fix them into absolute ones. The provider either doesn't know what they're talking about or what they actually mean is that you have file operations using `http://` paths somewhere in your code - if that's the case, you should indeed get rid of them sooner rather than later – Pekka May 28 '13 at 17:57
  • For the most part this is BS. The only real performance benefit is your your code becomes marginally smaller so the payload across the wire is smaller. –  May 28 '13 at 17:59
  • 1
    `"The tech guy who sent this isn't answering my followups."` - That's probably for the best. Unless there's something in the code we're not seeing (and his description isn't specifying), then he doesn't know what he's telling you. It *sounds* like you're just returning some 30* redirect responses, which are perfectly valid. (Of course, hopefully you're not bothering to return content with those responses, since that would be wasteful of resources.) – David May 28 '13 at 18:02
  • Thanks for the help guys! Pekka, by file operations do you mean stuff like editing/writing to a text file? –  May 28 '13 at 18:31
  • That tech is blowing smoke up your... Go find another hosting provider. – Michael Hampton May 29 '13 at 04:29
  • This situation could arise simply from people clicking on your internal links or from many assets being loaded as parts of the page. You can check if your php scripts don't needlessly read a file via http instead of by opening it on a local filesystem, but I doubt php would even send a referer. – Zdenek Jun 18 '18 at 19:53

1 Answers1

0

Both links take you to the same page, but there's a big difference in the way they perform. By using a relative path, the browser knows to just look within your own web site's server space for the linked file. However, if you use the absolute path, the browser goes back out onto the Internet and finds your site all over again, then finds the file within your directory. So, if you're linking to pages on your own site, using a relative path will make your site respond quicker. It's all about speed!

If you're linking to something off your site, then you must use the absolute path because there is no relative path to use.

Blames to Mr Boogie Jack

  • 2
    This is ridiculous. The client doesn't look at your server space. It does a DNS lookup to resolve the domain (which is then cached based on the TTL settings in your zone file). They are functionally equivalent. –  May 28 '13 at 18:57
  • Edited the 'thanks' to 'blames'. I guess I was trying to find the answer I wanted until I did...the thanks for you. –  May 28 '13 at 20:08