Skip to content

Question - Recommended expiration settingย #786

Closed

Description

@dmcweeney

Hi,

Quick question - I'm wondering what you recommended SlidingExpiration setting would/should be in relation to token lifetimes when using the distributed cache.

Thanks, Donal

Activity

  1. jmprieur commented on Nov 30, 2020

    @jmprieur
    Collaborator

    dmcweeney : this is an interesting question, but we'd want to understand your scenario a bit more:

    • do you have any concern?
    • do you see any issue?
  2. dmcweeney commented on Nov 30, 2020

    @dmcweeney
    Author

    Hi Jean-Marc Prieur (@jmprieur),

    No concerns from a security perspective.
    Thinking in terms of ensuring that the tokens are auto-purged/expired in a timely manner.
    For example,

    • you may have trial users that access the app and don't come back
    • and trial users that access the app and do come back a couple of times during a trial.
    • and "active" users that might access the app once a month
    • and "active" users that are actively accessing the app daily/weekly
    • and "active" users that may move on to another company and will never come back into the app.

    So it is really trying to balance the user accessing the app versus token purge (which would require the user to sign back into the app again) versus redis cache memory usage?

    Any thoughts greatly appreciated.

    Thanks, Donal

  3. Mek7 commented on Dec 11, 2020

    @Mek7

    Hi,
    I had the same question in the linked issue. It's not like any problem or bug, just a design decision.
    Now that I think of it, maybe we could set the tokens to never expire. Over time, they will get invalid and MSAL figures it out and forces re-auth anyway, correct?

  4. dmcweeney commented on Dec 15, 2020

    @dmcweeney
    Author

    Mek (@Mek7) correct its a design decision related to picking a good number...

    Over time, they will get invalid and MSAL figures it out and forces re-auth anyway, correct

    Correct however if the user does not come back to login, the entry stays in the redis cache and it will never get expired, eventually using all the allocated cache storage.

  5. jmprieur commented on Dec 15, 2020

    @jmprieur
    Collaborator

    Thanks Mek (@Mek7) dmcweeney for this discussion
    I've added a few sentences to the wiki: https://github.com/AzureAD/microsoft-identity-web/wiki/Token-cache-serialization#recommended-expiration-setting

    Closing this issue for now.
    Feel free to reopen if you disagree

  6. creativebrother commented on Jan 28, 2021

    @creativebrother
    Contributor

    Thanks Mek (@Mek7) dmcweeney for this discussion
    I've added a few sentences to the wiki: https://github.com/AzureAD/microsoft-identity-web/wiki/Token-cache-serialization#recommended-expiration-setting

    Closing this issue for now.
    Feel free to reopen if you disagree

    Hi Jean-Marc Prieur (@jmprieur), so if we have access token life time of 1 hour, we should set the cache expiration to, say 90 minutes to balance the cache storage and re-authentication traffic(give the refresh token a chance to work?).
    When using the default expiration of 20 minutes, the refresh token is never used because the ConfidentialClientApplication.GetAccountAsync(Id) will get nothing from cache due to the triggered cache purge on read, which leads to AcquireTokenSilent call fail and trigger re-authentication.
    So why do we end up with 20 minutes as the default, is it mainly the concern of the large system with huge cache entries?
    Of course the purge interval plays a role too, and the default is 30 minutes though. Is the 20 min + 30 min < 60 min (default access token life time) plays a role here?

  7. jennyf19 commented on Mar 18, 2021

    @jennyf19
    Collaborator

    creativebrother we've updated the documentation around cache eviction. thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    answeredquestionFurther information is requested

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions