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.
robots.txt (RFC 9309)
Section titled “robots.txt (RFC 9309)”The test cases of Google
Section titled “The test cases of Google”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
EXPECTof the file is one case, and each call of the helpersTestPathandTestEscapeis 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
httporhttpsURL. - 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:
ID_LineSyntax_Lineat 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.
GoogleOnly_AcceptUserAgentUpToFirstSpaceat 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.
ID_Encodingat 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.
ID_Encodingat 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.
ID_Encodingat 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.
GoogleOnly_IndexHTMLisDirectoryat 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'.
GoogleOnly_LineTooLongat line 539: "FooBot" on the long pathGoogle: 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.
GoogleOnly_LineTooLongat line 565: "FooBot" on the second long pathGoogle: 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.
ID_UTF8ByteOrderMarkIsSkippedat 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.
ID_UTF8ByteOrderMarkIsSkippedat 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.
ID_UTF8ByteOrderMarkIsSkippedat 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.
ID_UTF8ByteOrderMarkIsSkippedat 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.
The rules of the file
Section titled “The rules of the file”- A group. A group is one or more
user-agentlines and the rules after them (§2.1). Acrawl-delayline between twouser-agentlines does not start a new group. The crawler ignores a rule before the firstuser-agentline. Tests:robots.test.tskeeps 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.tsmatches 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.tsrefuses options that are not numbers, and a token that robots.txt cannot match. - The longest match. The longest matching rule decides, and
allowwins a tie (§2.2.2). Test:robots.test.tslets 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.tstreats * 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.tsmatches 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
/%7Ejoeand/~joeare equal (RFC 3986). Tests:robots.test.tscompares percent-encoded and plain forms as the same path,matches a rule with characters that the URL parser encodes.robots.property.test.tsgives the same decision for the percent-encoded and the plain form of an unreserved character. - The file itself. The path
/robots.txtis always permitted, and an emptydisallowline matches nothing. Tests:robots.test.tsalways allows /robots.txt itself.robots.property.test.tsalways 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.tsfollows 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.tsreads the fetch status: 4xx allows all; 5xx, 429 and silence allow nothing.hazards.test.tsreads 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.tsreads the fetch status: 4xx allows all; 5xx, 429 and silence allow nothing.crawler.test.tsfetches 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.tsis 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
304keeps the rules. Tests:hazards.test.tskeeps a robots.txt for 24 hours, then asks again.crawler.test.tskeeps 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-Afterof the server. Tests:hazards.test.tsuses 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.tsparses the first 500 KiB and no further.hazards.test.tsparses the first 500 KiB of a gzip robots.txt that decodes past the maximum.
More than RFC 9309
Section titled “More than RFC 9309”- 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.tstakes the longest crawl delay of the groups that apply, an agent's group included.hoststate.test.tsis 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 namesClaude-User. Tests:robots.test.tsapplies Claude-User's rules only where a site wrote them.mcp.test.tsfetch applies the robots.txt rules for Claude-User.
HTTP caching (RFC 9111)
Section titled “HTTP caching (RFC 9111)”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". Withauto, 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, notauto. Test:hazards.test.tsuses the freshness of the server with maxAgeMs auto, and keeps variants apart.- The lifetime. The lifetime comes from
max-ageinCache-Control, or else fromExpireslessDate(§4.2.1). The crawler takes away the value of theAgeheader (§4.2.3). It does not add the time that the response was in transit. Tests:hazards.test.tsuses 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 nomax-ageand noExpires, the lifetime is 10 percent of the time sinceLast-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.tsreads Expires, Age and Last-Modified for freshness, and keeps a no-store response. no-storeandno-cache. By policy, the crawler keeps a response withno-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-storeandno-cachemake the copy stale at once:autoasks the server again, and an explicitmaxAgeuses the copy. Tests:hazards.test.tsreads 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 thatVarynames (§4.1). A request with a different value gets a new response.Vary: *matches no request. The crawler sends the sameUser-Agentin each request, so aVaryon it changes nothing. Tests:hazards.test.tsuses 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-Matchwith the storedETagandIf-Modified-Sincewith the storedLast-Modifieddate (§4.3.1). A304gives 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.tsrevalidates with the stored ETag, and a 304 reuses the stored body.hazards.test.tssends 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
ETagat each response. A server examinesIf-None-MatchbeforeIf-Modified-Since(RFC 9110 §13.1.3), so such a server does not answer304at any time. After the same body comes back 3 times, the crawler sends onlyIf-Modified-Since, and it tries theETagagain after 20 requests or 7 days. The memo applies only when the stored copy has the two validators. Tests:validators.test.tsstops 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.
openCrawlerkeeps the memo inhosts.sqlite, so each process on the computer uses it, also after a restart. Tests:validators.test.tskeeps the memo in hosts.sqlite, so a new process sends the date alone at once.hoststate.test.tsshares 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.
Redirects and Retry-After (RFC 9110)
Section titled “Redirects and Retry-After (RFC 9110)”Redirects
Section titled “Redirects”- 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 notemore than 5 redirects. It has no other check for a loop. Test:hazards.test.tsstops an endless chain with an error after five redirects. - A bad
Location. The crawler records aLocationthat does not parse, or that is not anhttporhttpsURL, as the outcome of the request. It does not throw an error. Test:hazards.test.tsrecords 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.tschecks each redirect hop again. - Credentials. At a different origin, the crawler removes the
Authorization,CookieandProxy-Authorizationheaders, as the Fetch standard does. Test:hazards.test.tsdrops credentials at a different origin, redacts the Location and still follows it. - A stored redirect. A stored
301or308answers from the cache. A temporary redirect answers from the cache only while it is fresh. Test:hazards.test.tsanswers a permanent redirect from the cache, and asks again for a temporary one.
Retry-After
Section titled “Retry-After”- Two forms. The crawler reads
Retry-Afteras seconds, or as an HTTP date in one of its three forms (§10.2.3, §5.6.7). A different text, for example1.5or-5, gives no value. Tests:units.test.tsreads 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-Afterbefore the next request to the host. Test:crawler.test.tspaces 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.tsstops 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.tsbacks off with equal jitter, so a backoff is never less than half its step.
AI preference signals
Section titled “AI preference signals”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) andai-use=n(the vocabulary of the IETF AIPREF draft). The crawler reads them in theContent-SignalandContent-Usagelines of robots.txt and headers. A value can be a structured field (RFC 9651), so?0,"no"andnoare equal, and a no wins over a yes. Tests:units.test.tslets 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.tsreads an AI-input opt-out from the response. - A line in robots.txt. A
Content-SignalorContent-Usageline 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.tsapplies 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.tsis 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.tsdoes 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 thenoaiandnoimageaitags ofX-Robots-Tag. The opt-out changes nothing, because the crawler trains no model. Tests:units.test.tsreads 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-reservationandtdm-policyheaders 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.tsrecords the RSL license and the TDMRep reservation, and changes no verdict with them.crawler.test.tsrecords the TDMRep header and tags of a page with its signals, and keeps AI input unset. - RSL. The crawler records the
Licenselines 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.tsrecords the RSL license and the TDMRep reservation, and changes no verdict with them.
The crawler does not read these signals:
- the
robotsmeta tag of a page, for example<meta name="robots" content="noai"> - the other values of
X-Robots-Tag, for examplenoindexornosnippet: the crawler records the header, but these values do not stop a fetch - the file
/.well-known/tdmrep.jsonand the policy thattdm-policynames - the license file that an RSL
Licenseline names