The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 4,262 other subscribers

Maximum URL lengths

Posted by jpluimers on 2010/04/20

A client recently asked me what space should reserve to store URLs in their DBMS.

The plurality in the topic title is a hint: different systems have different limits on URL lengths.

But first:

Don’t use long URLs

If you use long URL’s (longer than say a coupe of 100 characters), then usually you have a problem.

First of all: short URL’s are easier to remember, index and search.

Second: long URL’s can pose problems.
It might be that your browser and server support them.
But a user might be behind an intercepting proxy (sometimes invisible to both you and your user) that imposes a URL limit.

In stead of long URLs with a HTTP GET, use shorter URLs with a HTTP POST.

Maximum URL lengths

Stackoverflow has a nice topic on URL lengths, some sites did research on this a while ago, and here is some more information I collected.

Let’s start with the official standard on this:

RFC 2616 (Hypertext Transfer Protocol — HTTP/1.1) states in section 3.2.1 that there is no limit to the length of an URI (URI is the official term for what most people call a URL).

It warns though about URI’s longer than 255 characters, because back then (1999!) some older clients and proxy systems don’t support that.

Then there is RFC 3986 (Uniform Resource Locator (URI): Generic Syntax) which does not impose a limit on the total length of the URL, but indicates in section 2.3.3 the hostname is limited to 255 characters (because of DNS limitations).

Boutell did some research on URL lengths in 2006.
Their recommendation is to be careful with URL’s longer than 2000 characters.

ASP FAQ did some research back in 2001.
The odd thing back then was that Netscape 3-4 supported 8k URLs, but Netscape 6 only supported 2000 characters.

Some specific products (partly from Boutell and ASP FAQ, partly from my own research):

General: there is no theoretical limit on the URL length

If you need to reserve space in your DBMS, make it large or unlimited.

Browsers

Let’s start with the client side.

Internet Explorer

Internet Explorer 4-8 have a maximum URL length of 2083 characters, but a practical limit of 2048 characters.

Internet Explorer 8 also supports Data URIs, and those are limited to 32kb in size.

There is report of a bug in Internet Explorer 6 and 7 when exporting URL shortcuts: they are being truncated to about 259 characters.
This  looks too much like the MAX_PATH value of 260 described here.

Firefox

Firefox seems to have no practical limit.

It stops displaying after 64k characters, but can server more than 100k characters.
This holds for Firefox 1.5 up until the current Firefox version.

Danny Thorpe found out the hard way that the internal limit some Firefox versions is about 40k.
See the comment he made.

WebKit: Chrome, Safari

I could not find any limits on Chrome and Safari. Both are based on WebKit and it seems to have similar limits as Firefox has.

Opera

Though Opera has their own codebase, they don’t have a practical URL length limit, about 200-thousand still works.

Servers

Apache

On stackoverflow, people have used the LimitRequestLine setting to support URLs longer than 128-thousand characters.

Internet Information Server

For IIS version 6 and 7, the default limit is 16 kilobytes, with a maximum of 16 megabytes.

Sharepoint

SharePoint imposes some extra limits on the fixed part of a URL and some explanation is in this Microsoft forum thread and this one.
The query string portion can be larger, but the fixed part is dynamic.

The above ling also has a reference to a URL Length Checker that you can use for SharePoint.

Lotus Notes

From version 6.5.3 on, the maximum URL length can be set in kilobytes. The default is 4 kilobytes.

NCT Research reports that older versions have a limit of 2048 characters (version 5.0.10 and up, including 6.x until 6.5.3), and versions below have a 1024 character limit.

Search engines

SEOmofo did some research on the maximum URL length of search engines.

They both researched the length for indexing URL’s and the length for displaying them in search results.

Their winner is BING: it supports up to 2047 characters.

Google supports up to 1855 characters.

–jeroen

8 Responses to “Maximum URL lengths”

  1. Nil said

    “Firefox”, not “FireFox”

  2. […] Not only browsers hate these long URLs, even the Search engines hate these longer URLs and it is also noted that Google dosen’t even care to index the URLs that 1855 characters or so. – Reference. […]

  3. When I was working on cross-domain data passing techniques a few years ago, I found by trial and error that Firefox’s URL limit was about 40k. This was not a display artifact, it was a significant chars limit for URL uniqueness. Two URLs that differed only at the Nth char or beyond appeared to be treated as the same URL. I think this was Firefox 1.x, but I’m not sure. We didn’t pursue this further when the same tests showed IE 6’s URL length tolerance was about 2k.

  4. BarryOw said

    Saving an HTML file to a name based on the URL is a problem. Windows already takes away this from the maximum file length of name (dependent on windows language) “C:\Documents and Settings\[username]\My Documents” (or \Desktop)

    And if you make backups, you will probably have some sort of subdirectory you will want to copy it into.

  5. A little bit nitpicking as usual :-)

    URIs are the superset of URLs. You are basically talking about the length issues that may come with URLs – as you refer to things like “http://www.domain.net/path..” or “ftp://ftp.domain.net.path…” These are actually URLs (and are URIs consequently)

    URLs always have a “loocation” part, which is a scheme (http: ftp: etc) plus a domain name (the “authority”). URIs as superset of URLs define the authority part as optional, i.e. something like tel:+491234567 or urn:isbn:1440480095 would be a valid URIs, but not URLs.

    Historically URLs were the first and only URIs.

    • jpluimers said

      I originally considered linking to URIs, URLs, and URNs: Clarifications and Recommendations 1.0, but then thought: let’s keep it at “(URI is the official term for what most people call a URL)”, and if/when Olaf kicks in, I still can elaborate a bit more.

      You are absolutely right. URLs are a subset of URIs.
      URNs are also a subset of URIs.
      URLs are meant to find something: they are locators.
      URNs are meant to identify something: they are names.
      The basic idea is that if you have identified something (i.e. ISBN number of a book), you still need a location to get that (for example, the spot on the shelve in the library where it is).
      You can have resolvers that give you a URL based on a URN.

      The most common URLs use the schemes http:, https:, ftp:, and mailto: (even though most people would omit the mailto: in daily life).
      There are many many more schemes.

      Getting into this stuff deeper requires much more space, so maybe I’ll post a bit more on this in the future.

      –jeroen

  6. Bhavesh Soni said

    Good one…

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.