Skip to content

Conversation

@smoreinis
Copy link
Collaborator

Summary

  • Adds reusable @cacheable decorator for HTTP cache headers
  • Applies cache headers to 9 GET endpoints across 4 route files
  • Reduces server load by enabling client-side caching

Changes

  • New src/api/cache.py: Decorator supporting max_age, private/public, stale-while-revalidate
  • agents.py: 60s cache for agent data (3 endpoints)
  • schedules.py: 60s cache for schedule config (2 endpoints)
  • spans.py: 300s cache for historical trace data (2 endpoints)
  • deployment_history.py: 300s cache for historical deployments (2 endpoints)

Usage

@router.get("/items/{id}")
@cacheable(max_age=60)
async def get_item(id: str, response: Response) -> Item:
    ...

Test plan

  • All existing tests pass (184/184)
  • Manual verification: Cache-Control header present
$ curl -i http://localhost:5003/spans 2>&1 | grep -i cache
cache-control: private, max-age=300

Add @Cacheable decorator for easy cache header management on GET endpoints.

Changes:
- New src/api/cache.py with reusable @Cacheable decorator
- Support for max_age, private/public, stale-while-revalidate
- Applied to 9 GET endpoints across 4 route files:
  - agents.py: 60s cache for agent data
  - schedules.py: 60s cache for schedule config
  - spans.py: 300s cache for historical trace data
  - deployment_history.py: 300s cache for historical deployments

Usage:
  @router.get('/items/{id}')
  @Cacheable(max_age=60)
  async def get_item(id: str, response: Response) -> Item:
      ...
@smoreinis smoreinis requested a review from a team as a code owner December 24, 2025 21:36
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.

2 participants