I am not sure how to troubleshoot it but I am trying to implement ASP.NET Output Cache via Redis Output cache provider.
We have Redis server (non-azure) set up and I can store cache for general usage. However, when I try to setup ASP.NET output cache, it doesn't seem to save anything to cache!
I have installed Microsoft.Web.RedisOutputCacheProvider via Nuget. Web.Config is set up with following:
<caching>
<outputCache defaultProvider="MyRedisOutputCache">
<providers>
<add name="MyRedisOutputCache" type="Microsoft.Web.Redis.RedisOutputCacheProvider" host="ServerName" port="6464" accessKey="PasswordToRedis" />
</providers>
</outputCache>
</caching>
The MVC controller is setup with OutputCache attribute:
[OutputCache(Duration = 3600, VaryByParam = "*", Location = OutputCacheLocation.ServerAndClient)]
public JsonResult GetLookupData()
When I check the Redis, I don't see any OutputCache being stored.
Am I missing something? Is there a way to debug why it is not storing anything in cache?
Ok this was really silly.
When you install RedisOutputCacheProvider via Nuget, you will get this small doco in your app/web.config:
<!-- For more details check https://github.com/Azure/aspnet-redis-providers/wiki --><!-- Either use 'connectionString' OR 'settingsClassName' and 'settingsMethodName' OR use 'host','port','accessKey','ssl','connectionTimeoutInMilliseconds' and 'operationTimeoutInMilliseconds'. --><!-- 'databaseId' and 'applicationName' can be used with both options. --><!--
<add name="MyRedisOutputCache"
host = "127.0.0.1" [String]
port = "" [number]
accessKey = "" [String]
ssl = "false" [true|false]
databaseId = "0" [number]
applicationName = "" [String]
connectionTimeoutInMilliseconds = "5000" [number]
operationTimeoutInMilliseconds = "1000" [number]
connectionString = "<Valid StackExchange.Redis connection string>" [String]
settingsClassName = "<Assembly qualified class name that contains settings method specified below. Which basically return 'connectionString' value>" [String]
settingsMethodName = "<Settings method should be defined in settingsClass. It should be public, static, does not take any parameters and should have a return type of 'String', which is basically 'connectionString' value.>" [String]
loggingClassName = "<Assembly qualified class name that contains logging method specified below>" [String]
loggingMethodName = "<Logging method should be defined in loggingClass. It should be public, static, does not take any parameters and should have a return type of System.IO.TextWriter.>" [String]
redisSerializerType = "<Assembly qualified class name that implements Microsoft.Web.Redis.ISerializer>" [String]
/>
It indicates the default value for "ssl" would be false. However, reading through the code itself, it is actually defaulted to true.
So explicitly setting ssl to false have fixed it.
EDIT
Oh and I had to downgrade RedisOutputCacheProvider to 1.7.5.
3.0.1 didn't work at all for me.