-
Notifications
You must be signed in to change notification settings - Fork 656
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
Support maxage for uplinks #47
Conversation
Thanks for creating this pull request. It works, but this solution will overwrite So I think I'm going to rewrite it using in-memory cache (and add a few missing timers we planned to add a few months ago). |
Good point. It should be possible to address your concern without something as dramatic as a rewrite though. I'll look into this when I get a chance. |
Wait a second, why would this be overwriting package.json on every request? I added the condition to also write package.json only if the fetched time doesn't match what we currently have. The |
On every request to upstream. If this option is on by default (which is desirable), and has a small value (a few minutes), taking into account npm's behaviour to create 100 requests at a time... On the other hand, if you set up huge maxage and expect it to survive restarts, your approach is correct. /me thinks about benchmarks |
Oh, right. I was so focussed on my use-case I forgot other ones exist. Oops xD Uh so that seems like it should still be easy to fix. I just need to short-circuit the ... Right? :) |
It adds about 10% in the worst case when the uplink is very fast (i.e. local couchdb), 15 vs 17 seconds for 1000 sequential requests in my weird test case. Doesn't matter with default registry though.
It's not about zero maxage, it's about very small maxage. If What is your use-case anyway? |
I will be deploying sinopia to proxy our organisations internal NPM mirror. We have offices and build agents in a few different continents, I want to make sure "hot" packages are cached geographically close to each of these locations. Because we're also maintaining a complete mirror of the upstream NPM registry (to shield us from the seemingly endless outages it's been having lately), I can inexpensively follow registry package changes and invalidate caches at each proxy location, so I plan on setting a very high max-age (24 hours or more) to make sure NPM is blazingly fast for us. |
Well, in this case you're right, it's the only logical option. Thanks, I'll merge this. Suggestions about how to not end up with two different pieces of code for the same function (depending on whether maxage is small or large) are appreciated. :) |
Adds support for the maxage config property of uplinks.