-
Notifications
You must be signed in to change notification settings - Fork 115
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
base: main
Are you sure you want to change the base?
Added the logic to increase the response cache maxAge for /schedule/id #10383
Conversation
Signed-off-by: Harsh Sawarkar <[email protected]>
const expirationTime = utils.nsToSecNs(schedule.expiration_time); | ||
const consensusTimestamp = utils.nsToSecNs(schedule.consensus_timestamp); | ||
|
||
if (schedule.deleted || (executedTimestamp && executedTimestamp !== '')) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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;
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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"
},
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