Skip to content

Change cache settings to decrease latency on most queries#348

Open
brian-lawrence-math wants to merge 2 commits into
tldr-pages:mainfrom
brian-lawrence-math:latency
Open

Change cache settings to decrease latency on most queries#348
brian-lawrence-math wants to merge 2 commits into
tldr-pages:mainfrom
brian-lawrence-math:latency

Conversation

@brian-lawrence-math
Copy link
Copy Markdown

@brian-lawrence-math brian-lawrence-math commented May 2, 2026

When I run the simple invocation tldr <command>, the code typically fetches the page from the internet, resulting in a 3-5 second delay before the tldr page displays. I think this is caused by cache settings:

  • By default, tldr only downloads pages when I access them.
  • By default, tldr only shows cached pages if they are less than one week old.

The delay is annoying. I'd suggest changing default behavior to make more use of the cache. Here (this PR) is one proposal:

  • Run update_cache() to download all pages for the language:
    • when tldr <command> first runs
    • when tldr <command> is run and the cache hasn't been updated in at least one month
    • when the user runs tldr -u to force a manual update.
  • Default to no maximum age for the cache: if a page is available in the cache, it displays regardless of age.

--

Notes and tradeoffs.

Cost to store all the pages? The cache with all the pages (English, all platforms) is ~28MB -- small. No harm in downloading and storing it.

Need to update pages frequently? Only a small fraction of pages are updated in any given month, and very few of those updates are critical. Look at modified dates on the tldr repo.

--

Yes, I know I can avoid this issue in other ways.

  • manual update tldr -u every week
  • set TLDR_CACHE_MAX_AGE environment variable.

But more aggressive caching is a better default for new users.

@brian-lawrence-math brian-lawrence-math marked this pull request as ready for review May 3, 2026 00:14
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.

1 participant