Dnn.platform: When using the Cacheable attribute on models in custom modules, how long are items cached for?

Created on 1 Apr 2019  路  4Comments  路  Source: dnnsoftware/Dnn.Platform

Summary

The Cacheable attribute that may be applied to models in custom module developments contains a parameter for CacheTimeOut. How is this parameter used to calculate cache expiration time?

Extended description

https://github.com/dnnsoftware/Dnn.Platform/blob/584b0f54bd6b6d237594dd9f96053f14db0b1a53/DNN%20Platform/Library/ComponentModel/DataAnnotations/CacheableAttribute.cs#L81 states that the CacheTimeOut parameter is multiplied by the "Host Performance Setting to determine the actual timeout value" - Where is the "Host Performance Setting" that this is referencing? What are the corresponding times used to calculate Sliding expiration in seconds, milliseconds or other time-based values?

Affected version

  • [x] 9.3.0
  • [x] 9.2.2
  • [x] 9.2.1
  • [x] 9.2
  • [x] 9.1.1
  • [ ] 9.1
  • [ ] 9.0

Most helpful comment

The CacheTimeOut parameter is multiplied by the PerformanceSetting

https://github.com/dnnsoftware/Dnn.Platform/blob/435adfc24e7e5c4fa8733a6b1c70dc4effbfecfd/DNN%20Platform/Library/Common/Globals.cs#L119-L137

The default value for CacheTimeOut is 20. Lets say you have HeavyCaching enabled. This would cache _most_ objects for 2hrs (120minutes). However, some core objects use non-default CacheTimeOut values.

For example, portal aliases are have an initial value of 200 (so 20hrs cached in HeavyCaching). On the shorter side of things, Captcha tokens have a CacheTimeOut value of 2 (6mins in HeavyCaching). You should be able to sit on a page for 5 minutes in that configuration and the Captcha token would still be valid, however if you waited 7 minutes it should fail.

All 4 comments

I am following this because I also have the same question, would be nice to add the details of how this works in the new Dnn Docs when we know the details.

The CacheTimeOut parameter is multiplied by the PerformanceSetting

https://github.com/dnnsoftware/Dnn.Platform/blob/435adfc24e7e5c4fa8733a6b1c70dc4effbfecfd/DNN%20Platform/Library/Common/Globals.cs#L119-L137

The default value for CacheTimeOut is 20. Lets say you have HeavyCaching enabled. This would cache _most_ objects for 2hrs (120minutes). However, some core objects use non-default CacheTimeOut values.

For example, portal aliases are have an initial value of 200 (so 20hrs cached in HeavyCaching). On the shorter side of things, Captcha tokens have a CacheTimeOut value of 2 (6mins in HeavyCaching). You should be able to sit on a page for 5 minutes in that configuration and the Captcha token would still be valid, however if you waited 7 minutes it should fail.

Thanks @ohine! This answered my question.

Anytime! I鈥檓 going to close this issue. If you have any other issues related, feel free to reopen it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

trouble2 picture trouble2  路  4Comments

mnouraei picture mnouraei  路  5Comments

trouble2 picture trouble2  路  5Comments

david-poindexter picture david-poindexter  路  3Comments

Roylej picture Roylej  路  3Comments