Skip to content

fix(date): improve caching accuracy #3887

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

Merged
merged 1 commit into from
May 19, 2025

Conversation

Patryk27
Copy link
Contributor

@Patryk27 Patryk27 commented May 8, 2025

CachedDate gets updated every second, but the current logic doesn't take into account milliseconds and nanoseconds - if the application starts at 12:00:00.600, hyper will report date: ...T120000 up until 12:00:01.600, which is overzealous.

We can sidestep this by subtracting the nanoseconds part (which includes milliseconds) from the time passed to CachedDate::update(), essentially rounding self.next_update to the beginning of the next closest second.

`CachedDate` gets updated every second, but the current logic doesn't
take into account milliseconds - if the application starts at
`12:00:00.600`, hyper will report `date: ...T120000` up until
`12:00:01.599`, which is overzealous.

We can sidestep this by subtracing the nanoseconds part (which includes
milliseconds) from the time passed to `CachedDate::update()`.
Copy link
Member

@seanmonstar seanmonstar left a comment

Choose a reason for hiding this comment

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

Cool, thanks!

@seanmonstar seanmonstar merged commit 436cadd into hyperium:master May 19, 2025
22 checks passed
@Patryk27 Patryk27 deleted the fix/date-accuracy branch May 20, 2025 07:53
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