Blog Post

Microsoft Mission Critical Blog
1 MIN READ

Re: Token Cache Service Inside D365 CE Plugin Base

angelonic's avatar
angelonic
Copper Contributor
Oct 10, 2025

How did you manage the hosts? Since it's a distributed system, the in-memory cache is only valid on the host running the plugin.

How did you manage cache updates on the various hosts?

Updated Oct 10, 2025
Version 3.0

3 Comments

  • PravinT's avatar
    PravinT
    Icon for Microsoft rankMicrosoft

    Good point! CE plugins are designed for a sandboxed, serverless SaaS model, so the focus isn’t on underlying hosting but on reducing token calls from thousands to a handful. It’s an optional optimization for cases where that few seconds of token fetch time matters.

    • angelonic's avatar
      angelonic
      Copper Contributor

      Yes, absolutely! However, the cache can be used more generically and to save queries to the dataverse. It's a shame that it's not possible to create a “real-time” invalidation system for all hosts.

      Anyway, thanks a lot for the tip!

      • PravinT's avatar
        PravinT
        Icon for Microsoft rankMicrosoft

        You make an excellent point—those robust caching strategies are certainly more applicable when building custom line-of-business (LOB) applications rather than SaaS solutions like Dynamics 365.

        Please note, this example is NOT intended to encourage caching Dataverse data inside plugins; we kindly ask that this approach be avoided. Our guidance remains to always access Dataverse data through IOrganizationService inside of Plugins.

        Please understand, the tip here is simply about reducing costly, presumably external calls where possible—not about expanding this idea aggressively across scenarios. It’s meant for very specific cases where external dependencies can be optimized, not as a general pattern.