Document CacheAutoTrimInterval & CacheMaxAge
Question asked by Pavan Chaudhari - February 25 at 9:57 PM
I want delete my cache in 5 min
what should be the values  CacheAutoTrimInterval & CacheMaxAge

I tried code below  but output is uncertain.

 DocumentUltimateWebConfiguration.Current.CacheAutoTrimInterval = System.TimeSpan.Parse(00:05);
 DocumentUltimateWebConfiguration.Current.CacheMaxAge = System.TimeSpan.Parse(00:03);

Pavan Chaudhari

1 Reply

Reply to Thread
Cem Alacayir Replied
Employee Post Marked As Answer
In your code you are not passing a string (no double quotes) to TimeSpan.Parse method. It should be TimeSpan.Parse("00:05") not TimeSpan.Parse(00:05). Do you mean you get a compile error with "but output is uncertain" ? 

When setting TimeSpan properties in code, you can use this:

DocumentUltimateWebConfiguration.Current.CacheAutoTrimInterval = TimeSpan.FromMinutes(5);
DocumentUltimateWebConfiguration.Current.CacheMaxAge = TimeSpan.FromMinutes(5);

This is same as parsing the string representation:

DocumentUltimateWebConfiguration.Current.CacheAutoTrimInterval = TimeSpan.Parse("00:05");
DocumentUltimateWebConfiguration.Current.CacheMaxAge = TimeSpan.Parse("00:05");

This can also be set in <appSettings> of Web.config:

  <add key="DocumentUltimateWeb:CacheAutoTrimInterval" value="00:05" />
  <add key="DocumentUltimateWeb:CacheMaxAge" value="00:05" />

Reply to Thread