Quieter request logs, and a robots.txt that keeps crawlers to /bibrefs - #967
Merged
Merged
Conversation
Two sources of noise in the production logs: - Clever Cloud's monitoring agent (Telegraf) polls / from the instance itself every minute and gets a 404, which was logged at warn. - Bots asking for /, /robots.txt and the like get 404s too, also at warn. Neither deserves a warning. Log 404s at info, and don't log requests whose socket address is the loopback interface at all: in production every real request comes through the load balancer, so a loopback address can only be the platform's own agent. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ln7Js7WaWpJHDVkEUwtFkA
Serve a /robots.txt that allows /bibrefs (the full dump and the refs= lookups alike) and disallows everything else, and send X-Robots-Tag: noindex on every response. /bibrefs has to stay open to crawlers: ReSpec builds the references section of a spec in the browser by calling it, and search engines render JavaScript when they index a page while honouring robots.txt for the requests the page makes, so blocking it would strip the bibliography from every ReSpec draft in their index. The full dump is served from a cache and carries an ETag, so a crawler fetching it costs nothing to speak of. Search, reverse lookup and metadata aren't needed to render anyone's page and are off limits. The noindex header keeps any of the API's responses, allowed or not, from ever showing up as a search result. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ln7Js7WaWpJHDVkEUwtFkA
The why lived both in comments in index.js and in the docs. Keep it in the docs and have the code point there. The policy itself moves to a robots.txt file at the root of the repository, which the route serves and the docs link to, instead of being spelled out in both. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ln7Js7WaWpJHDVkEUwtFkA
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two small follow-ups to #965 and #966, from what the production logs showed once they went live.
1. Quieter request logs
Two sources of noise:
127.0.0.1) polls/every minute and gets a 404, which was logged atwarn./,/robots.txtand the like get 404s too, also atwarn.Now:
info. Other 4xx stay atwarn, 5xx aterror.request completedline nor the debugrequest receivedone). In production every real request comes through the load balancer, so a loopback socket address can only be the platform's own agent. The check is on the socket address, not onreq.ip, so a forwardedX-Forwarded-For: 127.0.0.1doesn't hide a request.2. robots.txt and noindex
/robots.txtis served (it was a 404) with:and every response carries
X-Robots-Tag: noindex./bibrefshas to stay open to crawlers: ReSpec builds the references section of a spec in the browser by calling it, and search engines render JavaScript when they index a page while honouringrobots.txtfor the requests the page makes, so blocking it would strip the bibliography from every ReSpec draft in their index. Since #966 the full dump is served from a cache with anETag, so a crawler fetching it costs nothing to speak of. Search, reverse lookup and metadata are not needed to render anyone's page and are off limits. Thenoindexheader keeps any of the API's responses, allowed or not, from ever showing up as a search result.Both documented in
DEPLOYMENT.md.Testing
Full suite passes (366,309 tests), including new tests for
robots.txt(status, content type, caching, exact body) and for thenoindexheader on every kind of response (health, robots, lookups, full dump, metadata, 404). Checked by hand with the server bound on a non-loopback address that/and/robots.txtlog at info with their 404, a throwing request still logs at error with the stack, and the same requests over127.0.0.1produce no request lines.🤖 Generated with Claude Code
https://claude.ai/code/session_01Ln7Js7WaWpJHDVkEUwtFkA