Maven Virtual Registry: Cache logic
🔭 Issues plan
- Maven Virtual Registry: Database models (#467972 - closed).
- Maven Virtual Registry: Permissions policy (#467977 - closed).
- Maven Virtual Registry: Registry models API (#467979 - closed).
- Maven Virtual Registry: Maven API endpoint (#467982 - closed).
-
Maven Virtual Registry: Cache logic (#467983 - closed).
👈 You're here. - Maven Registry: Cached responses destruction (#468113 - closed).
- Improve workhorse dependencyproxy logic (#461561 - closed).
- Maven Virtual Registry: Documentation (#468115).
- Maven Virtual Registry: Performance review (#468116).
- Maven Virtual Registry: feature flag cleanup (#468117).
🗒 Description
Cold cache or when the related cached response doesn't exist:
- Use workhorse
senddependency
logic to return and upload the response from upstream.- At this time, record the
ETag
sent by upstream. - Set the
upstream_etag_checked_at
to now. - Set the
downloaded_at
to now. - Set the
download_count
to1
.
- At this time, record the
Warm cache or when the related cached response exist:
- Check if now is within [upstream_etag_checked_at, upstream_etag_checked_at + cache_validity_period_hours].
- If that's the case, use workhorse
sendurl
to send the cached_response.- Set the
downloaded_at
to now. - Set the
download_count
to+1
.
- Set the
- If that's not the case, ping the related upstream to get the
ETag
header (HEAD
request).- If the
ETag
is the same, use workhorsesendurl
to send the cached_response.- Set the
upstream_etag_checked_at
to now. - Set the
downloaded_at
to now. - Set the
download_count
to+1
.
- Set the
- If the
ETag
is not the same (stale cached response), destroy the cached_response and use workhorsesenddependency
logic to return and upload the response from upstream.- At this time, record the
ETag
sent by upstream. - Set the
upstream_etag_checked_at
to now. - Set the
downloaded_at
to now. - Set the
download_count
todownload_count
of the destroyed cached_response +1
. (thedownload_count
carries over the cached response destruction.)
- At this time, record the
- If the
- Special case:
ETag
header is missing from upstream. Execute the "ETag is not the same" branch.
- If that's the case, use workhorse
Edited by David Fernandez