Skip to content

Cache sitemap discovery results to avoid re-fetching on every run #76

Description

@brylie

Discovery for a sitemap-backed source (discovery.source: sitemap) re-fetches every sitemap document from scratch on each discover <site> invocation — there is no caching keyed by discovery.cache_ttl_hours, even though docs/specs/crawler-improvements.md's example configuration and "Scale and timeline" section call this out explicitly: migri.fi and dvv.fi's sitemap index alone costs ~2.4–2.5 hours to enumerate at their mandated 5s Crawl-delay, and that cost "should be paid roughly once a day at most per source, not on every run."

Discovered while auditing #74's Phase 1 implementation before building Phase 2 rendering (#75) on top of it.

Scope

  • Add a discovery.cache_ttl_hours field to DiscoveryConfig (crawler/tapio_crawler/config/config_models.py), matching the spec's example config.
  • Cache the sitemap fetch/parse result (crawler/tapio_crawler/discovery/sitemap.py) for that TTL, so a discover run within the window reuses the manifest's existing discovery state instead of re-enumerating every child sitemap.
  • A run past the TTL performs a full re-fetch as today.

Acceptance criteria

  • Given a source was discovered less than cache_ttl_hours ago, when discover runs again, then no sitemap or child-sitemap HTTP requests are made.
  • Given the TTL has elapsed, when discover runs, then it re-fetches as it does today.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ragRetrieval pipeline

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions