Maximum length of URL fragments (hash)
Asked Answered
W

4

35

Is there a length limit for the fragment part of an URL (also known as the hash)?

Warily answered 15/10, 2009 at 11:24 Comment(1)
There is no standard for the hash as it is client-side only, but the limit is generally very high.Lemire
U
-2

There is definitely a length for the whole url.

Read

RFC2616 - Hypertext Transfer Protocol

Maximum URL length is 2,083 characters in Internet Explorer

Undoubted answered 15/10, 2009 at 11:28 Comment(3)
RFC2616 doesn't mention fragments except to say: "The URI MUST NOT include a fragment"Swage
This did not answer the questionAutobiography
Fragments are client-side. This is not a valid answer.Pillage
I
25

The hash is client side only, so the rules for HTTP may not apply to it.

Isidoro answered 28/9, 2011 at 14:39 Comment(1)
The "hash" is actually the URL Fragment and is not sent to the server, hence the length limitation from a server perspective doesn't apply.Struma
G
22

It depends on the browser. I found that in safari, chrome, and Firefox, an URL with a long hash is legal, but if it is a param send to the server, the browser will display an 414 or 413 error.

for example: an URL like http://www.stackoverflow.com/?abc#{hash value with 100 thousand characters} will be ok. and you can use location.hash to get the hash value in javascript but an URL like http://www.stackoverflow.com/?abc&{query with 100 thousand characters} will be illegal, if you paste this link in the address bar, a 413 error code will be given and the message is the client issued a request that was too long. If that is a link in a web page, in my computer, Nginx response the 414 error message.

I don't know the situation in IE.

So I think, the limitation of the length of URL is just for transmission or HTTP server, the browser will check it sometimes, but not every time, and it will always be allowed to be used as a hash.

Gate answered 10/9, 2014 at 7:28 Comment(1)
Did you find any official (docs) information regarding the client side limitations (or lack thereof)?Onanism
T
0

In general, the web platform does not have limits on the length of URLs (although 2^31 is a common limit). Chrome limits URLs to a maximum length of 2MB for practical reasons and to avoid causing denial-of-service problems in inter-process communication.

Tadich answered 26/11, 2023 at 18:45 Comment(0)
U
-2

There is definitely a length for the whole url.

Read

RFC2616 - Hypertext Transfer Protocol

Maximum URL length is 2,083 characters in Internet Explorer

Undoubted answered 15/10, 2009 at 11:28 Comment(3)
RFC2616 doesn't mention fragments except to say: "The URI MUST NOT include a fragment"Swage
This did not answer the questionAutobiography
Fragments are client-side. This is not a valid answer.Pillage

© 2022 - 2024 — McMap. All rights reserved.