DIRACGrid / DIRACGrid/diracx

[Feature]: Cache static endpoint responses

Open
#835 1 comment 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Python
Stars
19
Forks
45
Avg merge
4d 23h
Merged PRs (30d)
12

Description

### User Story

As a DiracX operator,
I want the well-known endpoints (e.g. `/openid-configuration`, `/dirac-metadata`)
to avoid recomputing identical responses on every request,
so that the server spends less time and resources on repeated work.

### Problem

These endpoints rebuild their full response on each call, even though the result only changes when the DiracX configuration changes. Today the configuration version is tracked by its git hexsha: a natural signal for
"has anything actually changed?".

Before proposing a fix, **measure the current situation**: how expensive are these responses to build, how often are they called, and which endpoints actually matter?

`run_demo.sh` with `--enable-open-telemetry` option would help: you could get a dashboard presenting duration and size of the requests and responses here.

### Things to think about

- **Where** should caching live? (router, logic layer, in front of the server,
or on the client via HTTP cache headers)
- **How** is the cache invalidated so it never serves stale data?
- **Extensions:** extensions (e.g. gubbins) override some of these endpoints and
add their own logic on top. How does your approach behave for them — does it
help, or does it need to be reusable across layers?

### Definition of Done

- [ ] The current cost and call frequency of these endpoints is measured and
briefly documented in the issue/PR.
- [ ] Identical responses are not recomputed while the configuration is unchanged.
- [ ] Invalidation is correct: a config change is reflected without serving
stale data.
- [ ] The approach is shown to work (or its limitations documented) for an
extension like gubbins.
- [ ] Tests cover invalidation behaviour.
- [ ] Cache hits/misses are observable.

### Pointers (look, don't copy)

The codebase already solves similar problems — study how before inventing
something new:

- `cachetools.TTLCache` is used in a couple of places (search the tree).
- The `/config/` endpoint already does ETag / `304 Not Modified` caching keyed
on `config._hexsha`.

A previous draft attempt lives in PR #457 — review it critically, including
what reviewers raised, rather than taking it as the answer.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.