Skip to content

[Caching] Allow Caching on All? Tooltips #6914

@Nick2bad4u

Description

@Nick2bad4u

Code of Conduct

  • I agree to follow this project's Code of Conduct

What would you like to see changed?

Feature Request: Add Caching Support for Tooltips

Summary

Add caching support to oh-my-posh tooltips to improve performance and reduce API calls for tooltips that fetch external data.

Problem

Currently, MOST tooltips in oh-my-posh cannot be cached. This is particularly problematic for tooltips that make HTTP requests to external APIs (like package registries, or version checkers). Every time a tooltip is triggered, it makes a fresh network request, leading to:

  • Performance issues: Slow tooltip display due to network latency
  • Rate limiting: Potential API rate limit violations from repeated requests
  • Unnecessary network traffic: Redundant calls for the same data
  • Poor user experience: Tooltips that feel sluggish or unresponsive

Current Behavior

Most Tooltips execute their logic (including HTTP requests) every time they are displayed, with no caching mechanism available.

    {
      "background": "#c386f1",
      "foreground": "#ffffff",
      "leading_diamond": "",
      "properties": {
        "method": "GET",
        "url": "https://registry.npmjs.org/eslint/latest"
      },
      "style": "diamond",
      "template": "<b> ESLint: v{{ .Body.version }}</b> ",
      "tips": [
        "eslint",
        "npm run lint"
      ],
      "trailing_diamond": "",
      "type": "http"
    },

Currently every time I type "eslint" or "npm run lint" it has to make an http API calls to fetch the latest version. Caching this would be useful since it doesn't change very often.

Proposed Solution

Add caching support to tooltips similar to how segments support caching, with the following features:

1. Cache Configuration

Allow tooltips to specify cache settings

Benefits

  1. Performance: Tooltips display instantly after the first request
  2. Reliability: Reduces dependency on external service availability
  3. User Experience: Snappy, responsive tooltips
  4. API Compliance: Prevents rate limit violations
  5. Resource Efficiency: Reduces network traffic and CPU usage

Use Cases

  • Package version tooltips: Cache NPM, PyPI, or other package registry lookups
  • Version checks: Cache GitHub release or version API calls
  • External service status: Cache health checks or status endpoints
  • Being able to cache the http response for ipv6, version, etc so it doesn't make a call out every time.

This would cache the httpnresponse for 24 hours per session, dramatically improving tooltip responsiveness while keeping the data reasonably fresh, while also not spamming the service endpoint for Apify.. etc

If you want me to help you implement this, let me know and I can give it a shot.

Metadata

Metadata

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions