Controlling asp net caching in code Part 12104:33

  • 0
Published on October 27, 2017

Text version of the video

Slides

All ASP .NET Text Articles

All ASP .NET Slides

All Dot Net and SQL Server Tutorials in English

All Dot Net and SQL Server Tutorials in Arabic

The basics of caching are discussed in Part 119, and caching multiple responses for a single webform are discussed in Part 120. In both of these videos, we discussed about controlling caching within the Webform HTML using the OutputCache directive. In this video, we will discuss about controlling caching in code.

“Cache” property of the “Response” object, can be used to control caching in code. “Response.Cache” property returns the “HttpCachePolicy” object, which can be used in code just like the “OutputCache” directive is used in webform’s HTML.

1. SetExpires() method, is used to set the duration for which we want to cachs the webform. This is similar to the “Duration” attribute of the “OutputCache” directive.
2. Response.Cache.VaryByParams[“None”] = true. This is similar to setting VaryByParam=”None” for the “OutputCache” directive.
3. To control the location where items are cached, we can use “Location” attribute of the “OutputCache” directive, and SetCacheability() method in code.

Enjoyed this video?
"No Thanks. Please Close This Box!"