Skip to content

Add cache refresh queries before TTL expiry#64

Open
AgbediaSamuel wants to merge 1 commit intobrutella:masterfrom
AgbediaSamuel:cache-refresh-rfc6762
Open

Add cache refresh queries before TTL expiry#64
AgbediaSamuel wants to merge 1 commit intobrutella:masterfrom
AgbediaSamuel:cache-refresh-rfc6762

Conversation

@AgbediaSamuel
Copy link
Copy Markdown

@AgbediaSamuel AgbediaSamuel commented Apr 7, 2026

Implements RFC 6762 Section 5.2 cache refresh queries in the browser.

Currently, LookupType sends a PTR query once at startup and then passively listens. When a cached record's TTL expires, the service silently disappears from the browse list even if it's still online.

This PR adds a refresh timer that re-sends the PTR query at 80% of the earliest cached record's TTL. If the service responds, the cache refreshes and the timer resets. If it doesn't respond, the TTL expires naturally and rmv fires as before.

Changes:

  • cache.go: Track earliest expiration across cached services, recalculate on removal
  • browse.go: Add refresh timer in the select loop, re-query before TTL expiry
  • cache_test.go: Tests for expiration tracking, recalculation on removal, empty cache

Fixes #63

Thank you for maintaining this project @brutella

Re-sends PTR queries at 80% of the earliest cached record's TTL,
preventing services from silently disappearing while still online.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Browser should re-query records before TTL expiry (RFC 6762 Section 5.2)

1 participant