Cache Commonly Used Select Lists in Application Object

Cache Commonly Used Select Lists in Application Object

You should always prefer to cache commonly used select lists in the Application object. In a typical Web application, you make a database server trip to get to the list. The list could be a list of states, a list of frequencies (monthly, annually, weekly, etc.), or a list of credit card types. Because the data in these kinds of lists are static, you can optimize the round trip to the database server by caching them in the Application object. Every time you need to display one such static list in your ASP page, first check in the Application object. If it is not there, then get it from the database and make sure that you cache it so that subsequent usage will retrieve it from the Application object instead of the database.

This implementation will save you at least one hit per list per page. You can decide on the format of the list. Because drop-down lists require

 Dim strListofStatesstrListofStates = Application("LIST_OF_STATES") If (strListofStates = "") Then     ' Get the list from database    ' Cache it in application object for subsequent usages    Application ("LIST_OF_STATES") = strListofStatesEnd IfResponse.Write strListofStates


Share the Post: