Open Closed

Feature Management Cache Invalidation #9467


User avatar
0
shodgson created

Hello,

I have a blazor web app solution based on the microservice template.

I'm trying to check if a feature is enabled or not within one of my custom microservice but the feature value does not get updated when I change the value in the features modal for a particular tenant i'm using. Is there something i'm missing? I want to have the feature value updated directly when check if the feature is enabled or not in my microservice.

My solution setup;

  • New feature defined within the FeatureDefinitionProvider of the administration service.
  • Login into the host and notice the new feature is there in the features modal for my tenant
  • Login in my tenant and navigate in a page that calls a microservice that uses that feature value to enable/disable the particular feature
  • Go back to the host and Enable the feature for my tenant
  • Go back to the tenant, navigate to the page and notice that the feature is still set the disabled in my service.

Is there some caching that does not get invalidate when updaing the feature value?

I tried waiting a long period of time and the feature value does not get updated I tried logout/login and the feature value is still the same.

Thanks


11 Answer(s)
  • User Avatar
    0
    AI-Bot created
    Support Team ABP Agent
    • In ABP microservice solutions, feature values are cached for performance. When you update a feature value (e.g., via the Features modal for a tenant), the cache in the relevant microservice is not immediately invalidated. This means your custom microservice may continue to use the old value until the cache expires or is refreshed.

    • By default, the cache duration is set internally and may not be short enough for immediate reflection of changes. Logging out/in or waiting may not help if the cache is still valid.

    • To ensure the feature value is updated immediately after a change, you need to manually clear or refresh the feature value cache in your microservice. This is a common scenario in distributed/microservice setups.

    • You can clear the feature cache by injecting and using the IFeatureValueStore or the distributed cache service for features, and removing the relevant cache entry when a feature is changed. Alternatively, you can reduce the cache duration in your configuration, but this may impact performance.

    • For more details and the official approach, see the documentation below.

    Sources:


    This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.

  • User Avatar
    0
    shodgson created

    I still need someone to provide a way to have the cache invalidated when updating features in the host so that I can confidently rely on the Feature Management module to configure feature flags for my application and deterministically know when those updates will be reflected in the application.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    The ApplicationConfigurationDtoCacheAbsoluteExpiration of AbpAspNetCoreMvcClientCacheOptions is five minutes by default.

    Can you try to change it to 10 seconds to test again?

    Thanks.

  • User Avatar
    0
    shodgson created

    [maliming] said: hi

    The ApplicationConfigurationDtoCacheAbsoluteExpiration of AbpAspNetCoreMvcClientCacheOptions is five minutes by default.

    Can you try to change it to 10 seconds to test again?

    Thanks.

    Thanks for the response.

    Where should I configure those options?

    I have a blazor web app for the front-end.

    I tried to;

        Configure<AbpAspNetCoreMvcClientCacheOptions>(options =>
        {
            options.ApplicationConfigurationDtoCacheAbsoluteExpiration = TimeSpan.FromSeconds(5);
        });
    

    In the blazor server; the feature value in my microservice is still not updated after 5 seconds In the microservice that check the feature; same thing

    Here's the simple snippet i'm using as an example in one of my service to condition on the feature value :

        public async Task<PagedResultDto<ResultDto>> GetResultsAsync(Guid id, GetResultsDto input)
        {
            // not updated based on the value set in the feature management from the host UI
            var isNewFlowEnabled = await featureChecker.IsEnabledAsync(AdministrationFeatures.NewFlow);
    
            if (isNewFlowEnabled)
            {
                return await GetNewResultsAsync(input);
            }
            else
            {
                return await GetLegacyResultsAsync(input);
            }
        }
    
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Hi

    You can configure it in blazor web app and blazor web app client projects.

    Because blazor web app has blazor server and wasm projects.

  • User Avatar
    0
    shodgson created

    [maliming] said: Hi

    You can configure it in blazor web app and blazor web app client projects.

    Because blazor web app has blazor server and wasm projects.

    Yes,

    but the AbpAspNetCoreMvcClientCacheOptions comes from the Volo.Abp.AspNetCore.Mvc.Client namespace wich can't work in the blazor client (WASM). I get ;

    There was no runtime pack for Microsoft.AspNetCore.App available for the specified RuntimeIdentifier 'browser-wasm'.

    Is there something I'm missing? Also, shouldn't this absolute expiration configuration be placed in my microservice project, since that's where I want to consume the feature value—not in the front-end?

    Additionally, I tried setting the tenant feature value to a different value again and waited for about 30 minutes, but the updated value still wasn't fetched by my service.

    Thanks.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Sorry, you only need to configure it in the Blazor Web app(Blazor Server) project.

    The Wasm refresh page will get the latest feature states.

  • User Avatar
    0
    shodgson created

    Hello,

    Not sure if I was clear enough but I already tried that with no success.

    Also, I don't see any relevance to set that configuration in the blazor server cause like I said I want the updated feature value in my backend microservice and not the ** front-end blazor. **

    thanks :)

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    To clear up the misunderstanding, could you share some code so I can reproduce the issue in a microservice template project?

    Thanks.

  • User Avatar
    0
    shodgson created

    Hello I did create a new boilerplate and found out that it was working in the boilerplate.

    I found out that the redis cache was not configured properly in my custom service and now it's working fine

    Thanks for the help !!

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Great

Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.0.0-preview. Updated on July 14, 2025, 11:57