We want to deploy our application in a distributed fashion but don't want to enable distributed caching.
From reading the documentation I'm not seeing an option to disable it. Is that true? What about a workaround like setting it to 0mins?
ASP.NET Core provides different kind of caching features. In-memory cache stores your objects in the memory of the local server and is only available to the application that stored the object. Non-sticky sessions in a clustered environment should use the distributed caching except some specific scenarios (for example, you can cache a local CSS file into memory. It is read-only data and it is the same in all application instances. You can cache it in memory for performance reasons without any problem).
6 Answer(s)
-
0
Hi @mdepouw
Redis cache basically acts as a database, so you don't have to configure anything else. All instances should get the latest value. Have you tried it ?
-
0
Redis cache basically acts as a database
Thanks (I get that)
Have you tried it?
No
what about my original question?
From reading the documentation I'm not seeing an option to disable it. Is that true? What about a workaround like setting it to 0mins?
I'm inferring from your response, the answer is "no, no way to disable it", is that correct? Any workarounds?
Thanks!
-
0
Hi,
You can totally delete Redis cache but in that case, you will face problems. Each instance will have different values. So, when you use Redis, basically, you are not using cache and it acts like as if you set cache lifetime to 0mins.
-
0
You can totally delete Redis cache but in that case, you will face problems. Each instance will have different values.
Sure, I could see that hence the underlying question, can we disable caching? Can we configure ASP.NET Zero to not cache anything? Seems like the answer is no.
Isn't the following how we configure the cache? If we set it to 0 ticks, won't every request to the cache be a miss effectively disabling the cache? What would be the negative side effects of that? Obviously potentially performance but would the application still work properly? Maybe slower, but properly?
public class OurApplicationModule : AbpModule { public override void PreInitialize() { ... Configuration.Caching.ConfigureAll(options => { options.DefaultSlidingExpireTime = new TimeSpan(0); }); } }
reference: cache configuration
So, when you use Redis, basically, you are not using cache and it acts like as if you set cache lifetime to 0mins.
Sorry, I'm not understanding that. Redis is used for caching by definition in this application. 🤔
-
0
Hi,
The Caching configuration you shared is for in-memory cache and we don't suggest using in-memory cache if you deploy multiple instances of your app. However, you can still use in-memory cache, set the
DefaultSlidingExpireTime
to 0 but this will cause a huge performance problem.You can still try it and see the result.
We suggest using Redis if you deploy multiple instances of your app to production.
-
0
copy that, thanks ismcagdas! 🤝