Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the logic to increase the response cache maxAge for /schedule/id #10383

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

HarshSawarkar
Copy link
Contributor

Description:

Increase cache max-age to 1 hour for finalized schedules to reduce unnecessary backend queries.

Related issue(s):

Fixes #10321

Notes for reviewer:

Checklist

  • Documented (Code comments, README, etc.)
  • Tested (unit, integration, etc.)

@HarshSawarkar HarshSawarkar requested a review from a team as a code owner February 14, 2025 13:50
@steven-sheehy steven-sheehy added enhancement Type: New feature performance rest Area: REST API labels Feb 14, 2025
@steven-sheehy steven-sheehy added this to the 0.124.0 milestone Feb 14, 2025
const expirationTime = utils.nsToSecNs(schedule.expiration_time);
const consensusTimestamp = utils.nsToSecNs(schedule.consensus_timestamp);

if (schedule.deleted || (executedTimestamp && executedTimestamp !== '')) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

executedTimestamp is sufficient. '' is falsey

Copy link
Contributor

@jnels124 jnels124 Feb 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a little easier to understand.

const hasExecuted = !!executedTimestamp || schedule.deleted;
const hasAutoExpired = !expirationTime && now >= consensusTimestamp + 1860;
const hasExpired = expirationTime && now >= expirationTime + 60;
const maxAge = hasExecuted || hasAutoExpired || hasExpired ? 3600 : 1;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this will break other tests as not all tests should result in the longer max age. Tests that rely on the different header value will need to be grouped into the same folder with each folder having the correct responseHeaders.json.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add a test case for explicitly expired and one for implicitly expired.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can look in the specs for examples of.

"features": {
      "fakeTime": "TIME_VALUE"
 },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Type: New feature performance rest Area: REST API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Increase response cache max-age for /schedules/{id}
3 participants