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

Cache Date timestamps up to the minute #160

Open
yoshuawuyts opened this issue Nov 27, 2020 · 2 comments
Open

Cache Date timestamps up to the minute #160

yoshuawuyts opened this issue Nov 27, 2020 · 2 comments
Labels
enhancement New feature or request

Comments

@yoshuawuyts
Copy link
Member

As pointed out by @Fishrock123 in https://github.com/http-rs/async-h1/pull/158/files#r530051517, Node.js caches timestamps for a minute, making it much easier to handle requests at a high volume. We should consider adopting this approach as well.

@yoshuawuyts yoshuawuyts added the enhancement New feature or request label Nov 27, 2020
@JakeChampion
Copy link

Here is a rust version which is similar in implementation to the Node.js version:

use cached::proc_macro::cached;

#[cached(size=1, time=60)]
fn utc_date() -> String {
    fmt_http_date(SystemTime::now())
}

I would contribute this but I'm not too sure how to write a test to exercise this feature yet.

@Fishrock123
Copy link
Member

Fishrock123 commented Dec 4, 2020

Given this is a perf change, a benchmark is probably more appropriate.

Also, regarding it being a perf change, it may be better to write this logic ourselves rather than go though the extra key-value map that is in cached, despite how neat that crate is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants