-
Notifications
You must be signed in to change notification settings - Fork 17
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
Improve Performance #97
base: development
Are you sure you want to change the base?
Conversation
every time a jwt is to be decoded, check in the node cache instead of decoding it everytime using the verifyIdToken method
Make unnecessary callbacks async to give a response to the client asap. Use lean and select mongoose functions
|
sources/apollo/server.js
Outdated
try { | ||
console.time("firebase"); | ||
|
||
let userToken = tokenCache.get(idToken); | ||
if (userToken === undefined) { | ||
const decodedToken = await firebaseApp.auth().verifyIdToken(idToken) | ||
// eslint-disable-next-line prefer-destructuring | ||
userToken={ uid: decodedToken.uid, mongoID: decodedToken.mongoID } | ||
tokenCache.set(idToken, userToken,36000); | ||
} |
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.
Scenario
at t=0, Firebase minted JWT for the user
at t=30 min, App sent that token to the server
This caches the JWT for 60 mins, whereas it should cache only for 30 mins
Ideally
Store the exp of the JWT when you cache and check it also
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.
Great Suggestion. Will do it soon! 🚀
Deployed to staging at http://staging.nitrkl.in/ |
|
This PR includes
Some Metrics