Skip to content

Standards

This page tells how polite-crawler follows the standards of the web, rule by rule. After each rule, a link goes to the test file on the branch main, and the name of the test follows in code font. CI does these tests on each change, on Linux, Windows and macOS.

When the crawler does not do a part of a standard, or does it in a different way, the page says so.

Google publishes its robots.txt parser with a test file, robots_test.cc. polite-crawler does each case of this file with its own parser. The repository keeps the file of commit a67394c byte for byte.

  • 201 cases. Each EXPECT of the file is one case, and each call of the helpers TestPath and TestEscape is one case.
  • 172 cases give the result of Google.
  • 12 cases differ on purpose. The list below gives the reason for each one. RFC 9309 gives most of the reasons.
  • 12 cases do not apply. Their input is not an absolute URL. polite-crawler decides only the path of an absolute http or https URL.
  • 5 cases do not apply. They count the lines that the parser does not know. polite-crawler ignores such a line (§2.2.4) and keeps no count.

The build of this page does the cases again, with the list of differences of the test. Thus the numbers on this page are the numbers of the test. Tests: robots.conformance.test.ts decides each case as Google does, except the differences that RFC 9309 asks for, has one case for each EXPECT of robots_test.cc.

The cases that differ on purpose:

  1. ID_LineSyntax_Line at line 79: "FooBot" on "http://foo.bar/x/y"

    Google: refused. polite-crawler: permitted.

    RFC 9309 §2.1: a line is a key, a colon and a value. Google guesses the colon of 'disallow /'. polite-crawler reads no line without a colon.

  2. GoogleOnly_AcceptUserAgentUpToFirstSpace at line 247: "Foo Bar" on "http://foo.bar/x/y"

    Google: refused. polite-crawler: permitted.

    RFC 9309 §2.2.1: a crawler matches its product token. polite-crawler reads the token of the agent 'Foo Bar' as 'foo' (productToken), and the file names that group. Google matches the whole value 'Foo Bar' and finds no group.

  3. ID_Encoding at line 419: "FooBot" on "http://foo.bar/foo/bar/ツ"

    Google: refused. polite-crawler: permitted.

    RFC 9309 §2.2.2: the octets outside US-ASCII are percent-encoded before the comparison. polite-crawler reads the path of a parsed URL, which is encoded, so '/foo/bar/ツ' is '/foo/bar/%E3%83%84'. Google asks the caller to encode the URL first.

  4. ID_Encoding at line 430: "FooBot" on "http://foo.bar/foo/bar/ツ"

    Google: refused. polite-crawler: permitted.

    RFC 9309 §2.2.2, as above: the unencoded '/foo/bar/ツ' is the encoded path, so the allow rule matches it.

  5. ID_Encoding at line 441: "FooBot" on "http://foo.bar/foo/bar/baz"

    Google: refused. polite-crawler: permitted.

    RFC 3986 §6.2.2.2: an escape of an unreserved character ('%62%61%7A') and the character ('baz') are equal, and polite-crawler normalizes both sides (normalizePath). Google compares the strings as written.

  6. GoogleOnly_IndexHTMLisDirectory at line 505: "foobot" on "http://foo.com/allowed-slash/"

    Google: permitted. polite-crawler: refused.

    Google-specific: Google reads 'index.html' at the end of a pattern as its directory. RFC 9309 has no such rule, so '/allowed-slash/' does not match '/allowed-slash/index.html'.

  7. GoogleOnly_LineTooLong at line 539: "FooBot" on the long path

    Google: refused. polite-crawler: permitted.

    Google-specific: Google cuts a line after 8 × 2083 bytes. polite-crawler reads each line whole, so the rule is not cut and does not match the path. RFC 9309 §2.5 sets a limit for the file, not for a line, and that limit is 500 KiB here.

  8. GoogleOnly_LineTooLong at line 565: "FooBot" on the second long path

    Google: permitted. polite-crawler: refused.

    Google-specific, as above: the second allow rule is not cut, so a path that only the cut rule matches stays disallowed.

  9. ID_UTF8ByteOrderMarkIsSkipped at line 898: report.valid_directives()

    Google: 2. polite-crawler: 0.

    RFC 9309 §2.3: the file is UTF-8. Two bytes of a byte order mark are not UTF-8, so the first line does not parse and its group is lost. Google skips a part of the mark.

  10. ID_UTF8ByteOrderMarkIsSkipped at line 906: report.valid_directives()

    Google: 2. polite-crawler: 0.

    RFC 9309 §2.3, as above: one byte of a byte order mark is not UTF-8, so the first line does not parse.

  11. ID_UTF8ByteOrderMarkIsSkipped at line 916: report.valid_directives()

    Google: 1. polite-crawler: 0.

    RFC 9309 §2.1: a rule outside a group is ignored. After the broken first line, the allow line is in no group, so polite-crawler does not keep it. The reporter of Google counts each line that it reads.

  12. ID_UTF8ByteOrderMarkIsSkipped at line 925: report.valid_directives()

    Google: 1. polite-crawler: 2.

    A byte order mark in the middle of the file is the character U+FEFF, which JavaScript reads as a space (String.prototype.trim). polite-crawler thus reads the allow line that follows it. Google sees an unknown line.

  • A group. A group is one or more user-agent lines and the rules after them (§2.1). A crawl-delay line between two user-agent lines does not start a new group. The crawler ignores a rule before the first user-agent line. Tests: robots.test.ts keeps one group when a crawl delay stands between two user-agent lines, ignores rules before any user-agent line, and an empty disallow.
  • The product token. The crawler matches its product token with no attention to case, and it ignores a version, for example PoliteCrawler/1.0 (§2.2.1). It merges the groups that name it. The group * applies only when no group names the crawler. Tests: robots.test.ts matches the product token case-insensitively, ignoring a version, merges groups that name the same crawler, reads the RFC's own example the way its appendix says.
  • A token that a file can name. A product token has only letters, _ and - (§2.2.1). The crawler does not start with a token that robots.txt cannot match. Test: hazards.test.ts refuses options that are not numbers, and a token that robots.txt cannot match.
  • The longest match. The longest matching rule decides, and allow wins a tie (§2.2.2). Test: robots.test.ts lets the longest match win, and allow win a tie.
  • Special characters. A * matches each sequence of characters, and a $ at the end of a pattern matches the end of the path (§2.2.3). The matcher uses no regular expression, so no pattern makes it slow. Tests: robots.test.ts treats * as any sequence and a trailing $ as the end, agrees with the RFC on stars and the end anchor, stays fast for patterns that freeze a backtracking regex. robots.property.test.ts matches a pathological pattern in linear time.
  • Percent-encoding. Before the comparison, the crawler encodes the characters outside US-ASCII in the path and in the rule (§2.2.2). It also decodes an escape of an unreserved character, so /%7Ejoe and /~joe are equal (RFC 3986). Tests: robots.test.ts compares percent-encoded and plain forms as the same path, matches a rule with characters that the URL parser encodes. robots.property.test.ts gives the same decision for the percent-encoded and the plain form of an unreserved character.
  • The file itself. The path /robots.txt is always permitted, and an empty disallow line matches nothing. Tests: robots.test.ts always allows /robots.txt itself. robots.property.test.ts always permits /robots.txt, and an empty Disallow never blocks.
  • Redirects. The crawler follows a maximum of 5 redirects for robots.txt, as §2.3.1.2 asks. After more redirects, it reads robots.txt as unreachable and fetches nothing from the site. The RFC also lets a crawler read this case as “unavailable”, which permits each path. polite-crawler does the stricter of the two. Test: hazards.test.ts follows five redirects for robots.txt, and reads a sixth as unreachable.
  • A 4xx status. A 4xx means that the file is unavailable, so each path is permitted (§2.3.1.3). This includes a 401 and a 403, and the crawler does not stop the host for them. Tests: robots.test.ts reads the fetch status: 4xx allows all; 5xx, 429 and silence allow nothing. hazards.test.ts reads a 401 or 403 on robots.txt as no robots.txt, and does not stop the host.
  • A 5xx, a 429 or no answer. The crawler reads robots.txt as unreachable, and it fetches nothing from the site (§2.3.1.4). A 429 is a 4xx, but the crawler reads it as unreachable, as Google does. Tests: robots.test.ts reads the fetch status: 4xx allows all; 5xx, 429 and silence allow nothing. crawler.test.ts fetches nothing from a site whose robots.txt cannot be read, and says why.
  • A web page in place of the file. A server can send a sign-in page or a challenge with a 200. The crawler reads such a body as unreachable, not as a file with no rules. RFC 9309 has no rule for this case. Test: robots.property.test.ts is unreadable, so nothing is permitted, and a plain robots.txt sent as text/html stays a file.
  • The cache of robots.txt. The crawler keeps a robots.txt for 24 hours (§2.4). Then it asks again with a conditional request, and a 304 keeps the rules. Tests: hazards.test.ts keeps a robots.txt for 24 hours, then asks again. crawler.test.ts keeps the rules of a robots.txt that a revalidation says has not changed.
  • A robots.txt that becomes unreachable. The crawler uses the last good copy of the file (§2.4). It asks for the file again after a wait of a few minutes, or after the Retry-After of the server. Tests: hazards.test.ts uses the last good robots.txt while robots.txt answers 503, and asks again minutes later, honors the Retry-After of an unreachable robots.txt before it asks again.
  • The size of the file. The crawler parses the first 500 KiB of the file, the minimum of §2.5. Tests: robots.test.ts parses the first 500 KiB and no further. hazards.test.ts parses the first 500 KiB of a gzip robots.txt that decodes past the maximum.
  • Crawl-delay. RFC 9309 does not define crawl-delay. The crawler obeys it, and it uses the longest delay of the groups that apply. Tests: robots.test.ts takes the longest crawl delay of the groups that apply, an agent's group included. hoststate.test.ts is the interval, the crawl delay, the slow answer or the Retry-After, the longest.
  • An agent for a person. When an assistant asks for a page through the MCP server, the crawler also obeys the rules for Claude-User. These rules apply only when a group names Claude-User. Tests: robots.test.ts applies Claude-User's rules only where a site wrote them. mcp.test.ts fetch applies the robots.txt rules for Claude-User.

The crawler is a private cache that keeps each response as the record of what a page said. The option maxAge of fetch tells when a stored copy answers in place of a new request.

  • maxAge: "auto". With auto, a stored copy answers only while it is fresh (§4.2). A number or a duration is a maximum age, and it wins over the freshness that the server gives. The command line and the MCP server take a duration, not auto. Test: hazards.test.ts uses the freshness of the server with maxAgeMs auto, and keeps variants apart.
  • The lifetime. The lifetime comes from max-age in Cache-Control, or else from Expires less Date (§4.2.1). The crawler takes away the value of the Age header (§4.2.3). It does not add the time that the response was in transit. Tests: hazards.test.ts uses the freshness of the server with maxAgeMs auto, and keeps variants apart, reads Expires, Age and Last-Modified for freshness, and keeps a no-store response.
  • A lifetime from Last-Modified. With no max-age and no Expires, the lifetime is 10 percent of the time since Last-Modified, and 24 hours at most (§4.2.2). This applies only to the statuses that RFC 9110 §15.1 calls heuristically cacheable, for example 200, 301 and 404. Test: hazards.test.ts reads Expires, Age and Last-Modified for freshness, and keeps a no-store response.
  • no-store and no-cache. By policy, the crawler keeps a response with no-store, because a stored copy is the proof of a citation. RFC 9111 §5.2.2.5 tells a cache not to keep such a response, so here the crawler differs on purpose. no-store and no-cache make the copy stale at once: auto asks the server again, and an explicit maxAge uses the copy. Tests: hazards.test.ts reads Expires, Age and Last-Modified for freshness, and keeps a no-store response, uses the freshness of the server with maxAgeMs auto, and keeps variants apart.
  • Vary. A stored copy answers only a request with the same values of the headers that Vary names (§4.1). A request with a different value gets a new response. Vary: * matches no request. The crawler sends the same User-Agent in each request, so a Vary on it changes nothing. Tests: hazards.test.ts uses the freshness of the server with maxAgeMs auto, and keeps variants apart, reads Expires, Age and Last-Modified for freshness, and keeps a no-store response.
  • Conditional requests. For a stored copy, the crawler sends If-None-Match with the stored ETag and If-Modified-Since with the stored Last-Modified date (§4.3.1). A 304 gives the stored body, and the capture log records a revisit (§4.3.4). When the stored body is not available, the crawler sends no validators. Tests: crawler.test.ts revalidates with the stored ETag, and a 304 reuses the stored body. hazards.test.ts sends no validators when the stored body is gone, so a 304 never comes back empty.
  • A memo of the validators of each host. Some servers change the ETag at each response. A server examines If-None-Match before If-Modified-Since (RFC 9110 §13.1.3), so such a server does not answer 304 at any time. After the same body comes back 3 times, the crawler sends only If-Modified-Since, and it tries the ETag again after 20 requests or 7 days. The memo applies only when the stored copy has the two validators. Tests: validators.test.ts stops the ETag after the same body comes back three times, and sends the date alone, probes the ETag after a number of requests or after an age, and starts it again on a 304, does not stop the ETag of a host that sends no Last-Modified date, gets 200 for the first revisits, then 304 when the crawler sends only the date.
  • One memo for each computer. openCrawler keeps the memo in hosts.sqlite, so each process on the computer uses it, also after a restart. Tests: validators.test.ts keeps the memo in hosts.sqlite, so a new process sends the date alone at once. hoststate.test.ts shares the validator memo between two stores on one file, and keeps it after a restart.

The crawler does not read s-maxage, private, must-revalidate, immutable, stale-while-revalidate or stale-if-error. It sends no Cache-Control header in a request.

  • A maximum of 5 redirects. The crawler follows a 3xx with a Location (§15.4), for a maximum of 5 redirects for each request. Then it stops with the note more than 5 redirects. It has no other check for a loop. Test: hazards.test.ts stops an endless chain with an error after five redirects.
  • A bad Location. The crawler records a Location that does not parse, or that is not an http or https URL, as the outcome of the request. It does not throw an error. Test: hazards.test.ts records a bad or non-http Location as an outcome, and never throws.
  • Each hop is a new request. The guard against private networks examines each new URL again. Test: egress.test.ts checks each redirect hop again.
  • Credentials. At a different origin, the crawler removes the Authorization, Cookie and Proxy-Authorization headers, as the Fetch standard does. Test: hazards.test.ts drops credentials at a different origin, redacts the Location and still follows it.
  • A stored redirect. A stored 301 or 308 answers from the cache. A temporary redirect answers from the cache only while it is fresh. Test: hazards.test.ts answers a permanent redirect from the cache, and asks again for a temporary one.
  • Two forms. The crawler reads Retry-After as seconds, or as an HTTP date in one of its three forms (§10.2.3, §5.6.7). A different text, for example 1.5 or -5, gives no value. Tests: units.test.ts reads Retry-After as seconds or as a date, reads only the two forms of Retry-After, so garbage gets the backoff and not a zero, reads the three forms of an HTTP date, and nothing else.
  • The wait. After a 429, a 502, a 503 or a 504, the crawler waits the time of Retry-After before the next request to the host. Test: crawler.test.ts paces one host and honors Retry-After.
  • The limit of a wait. The crawler waits for a maximum of 1 hour. When a server asks for a longer wait, the crawler does not sleep. It stops the host for the time that the server asks, for a maximum of 30 days. Until then, it skips each request to the host. Test: hazards.test.ts stops a host that asks for a wait past the budget, and backs off on a Retry-After it cannot read.
  • No Retry-After. With no value that it can read, the crawler backs off with equal jitter. The step starts at 5 seconds, doubles after each wait, and stops at 5 minutes. Each wait is between half the step and the full step. Test: units.test.ts backs off with equal jitter, so a backoff is never less than half its step.

A site can state how it permits the use of its content. The crawler records each statement with the capture. Only one statement changes what the crawler does: a no to AI input.

  • AI input. Two signals say no to AI input: ai-input=no (the content signals of Cloudflare) and ai-use=n (the vocabulary of the IETF AIPREF draft). The crawler reads them in the Content-Signal and Content-Usage lines of robots.txt and headers. A value can be a structured field (RFC 9651), so ?0, "no" and no are equal, and a no wins over a yes. Tests: units.test.ts lets a no anywhere win, and ignores training opt-outs, reads quoted and structured values, names the deciding line, and records a training opt-out. crawler.test.ts reads an AI-input opt-out from the response.
  • A line in robots.txt. A Content-Signal or Content-Usage line belongs to its group, and it can start with a path. In a group, the line with the longest matching path wins. A line before the first group applies to each crawler. Tests: robots.test.ts applies a usage line in the group that it is in, and on its path, reads crawl-delay, sitemaps and usage preferences.
  • What a no does. The crawler keeps the page, but it holds back the text from the AI reader. The fetch, the read, the search and the verification show no text of the page. An earlier version of the page stays held back. When a person gave the URL, the text comes back. Tests: runtime.test.ts is held back in the fetch, the read, the search and the verification, unless a person gave its URL, stays held back in an earlier version after the page drops the signal.
  • The MCP server. The word of the model is not sufficient to release the text. The server asks the user, and it releases the text when the user confirms. When the client cannot ask the user, the operator can turn on the release. Tests: mcp.test.ts does not release the text on the word of the model alone, asks the user when the client can ask, and releases the text when the user confirms, releases the text with the opt-in of the operator when the client cannot ask.
  • Training. The crawler records a training opt-out: ai-train=no, train-ai=n, and the noai and noimageai tags of X-Robots-Tag. The opt-out changes nothing, because the crawler trains no model. Tests: units.test.ts reads quoted and structured values, names the deciding line, and records a training opt-out, lets a no anywhere win, and ignores training opt-outs.
  • TDMRep. The crawler records the tdm-reservation and tdm-policy headers and the <meta> tags with these names (the TDM Reservation Protocol of the W3C). A reservation is about text and data mining, not about AI input, so it changes nothing. Tests: units.test.ts records the RSL license and the TDMRep reservation, and changes no verdict with them. crawler.test.ts records the TDMRep header and tags of a page with its signals, and keeps AI input unset.
  • RSL. The crawler records the License lines of RSL in robots.txt with the usage lines of the group. It does not fetch the license, and the line changes nothing. Test: units.test.ts records the RSL license and the TDMRep reservation, and changes no verdict with them.

The crawler does not read these signals:

  • the robots meta tag of a page, for example <meta name="robots" content="noai">
  • the other values of X-Robots-Tag, for example noindex or nosnippet: the crawler records the header, but these values do not stop a fetch
  • the file /.well-known/tdmrep.json and the policy that tdm-policy names
  • the license file that an RSL License line names