views:

236

answers:

6

Suppose for any url if a '//' is added instead on '/' by accident in the request. Can this effect the http request performance?

e.g.

  1. http://www.microsoft.com/downloads
    v/s
  2. http://www.microsoft.com//downloads

This reason I am asking this is; in one of our application the dynamic urls were building wrong on production server for some reason. We are fixing this issue but in the mean time I am really concern about what are the possible problem that may occur due to this?

+4  A: 

Well I don't know how exactly the URL is parsed server-side, but yes there will probably be a performance impact.

Or, well, impact is not the right word. It'll be a like a miniscule fly biting a massive mammoth...so you shouldn't really worry about it.

Of course, aside from performance, it would be nicer to just link to the correct URL. There might be other effects, and the URL might not work in the future.

Bart van Heukelom
Nice. I agree, it's probably not worth worrying about
Andy White
+1 for the mammoth-fly analogy! ;-)
Cerebrus
+1  A: 

I'm pretty sure that the performance impact is negligible or does not even exist.

Ronald Wildenberg
A: 

Trying with Firefox, seems that FF ask for GET http://www.microsoft.com//downloads receive a 301 Moved permanently and then FF ask for the correct address (and in this very case it receive another 301 pointing to http://www.microsoft.com/downloads/en/default.aspx) so yes, there is performance issue, server stress and is a wrong behaviour

(and probably different server configuration could act differently)

kentaromiura
You also get a redirect from http://www.microsoft.com/downloads to http://www.microsoft.com/downloads/en/default.aspx, so it isn't due to the double slash. A better test is that http://www.microsoft.com///downloads/en/default.aspx does not cause a redirect.
andynormancx
I think the new url shortening SO code needs some work :(
andynormancx
As I state depends by server configuration, url-rewrite or similar etc.. The point is that is a wrong behaviour, can cause server stress and is highly unreliable
kentaromiura
+2  A: 

The url you have posted does have a performance impact (ignoring the //). The fact that the url uses a re-direct (301 code) will slow the performance down as it re-directs from http://www.microsoft.com/downloads to http://www.microsoft.com/downloads/en/default.aspx.

This also happens when you forget to add the last trailing slash.

Stevo3000
+3  A: 

It's just coincidence that your URL's provided are redirecting to something that makes sense. If that is not the url you will get 404 on alot of servers.

http://slashdot.org/recent/

http://slashdot.org//recent/

Especially when you consider all the URL rewriting going on these days.

I have rewrite's that are like : ^http://site.com/directory/{0,1}$

Which would give you a nice 404 ;)

Chad Grant
A: 

No, there is no difference. Or at least you cannot appreciate the difference. Just compare doing

ls /<any-path>/myFile

with

ls /<any-path>//myFile

Luis

Luixv
You're comparing different things than the question. The question is related to URLs. The behaviour of // is dependent on the web server processing the request.
Steven
True. I am making an analogy. It depends on the server. The URL will be parsed, probably using a regexp which is nothing else than a finite automata which will deliver the path to the file system if the request is static (or a path to a cgi/application/whatever). Similar is the case of ls or any command accesing to the file system. The shell will parse the path using an analogous finite automata. You are right: it is definitely not the same. It is similar and back to the question: there is not measurable difference between both and not a reason for worrying.
Luixv
@Luixv coding directory traversal exploits, one SO post at a time ;)
Chad Grant