ASP.NET Caching - Pradeepa Chandramohan. What is Caching? Storing data in memory for quick access. In Web Application environment, data that is cached.

Slides:



Advertisements
Similar presentations
Chapter 6 Server-side Programming: Java Servlets
Advertisements

Chapter 31 Basic Form-Processing Techniques JavaServer Pages By Xue Bai.
Using JavaServer Pages Harry R. Erwin, PhD CIT304/CSE301.
J4www/jea Week 3 Version Slide edits: nas1 Format of lecture: Assignment context: CRUD - “update details” JSP models.
Python and Web Programming
XP Tutorial 9 New Perspectives on JavaScript, Comprehensive1 Working with Cookies Managing Data in a Web Site Using JavaScript Cookies.
1 The World Wide Web. 2  Web Fundamentals  Pages are defined by the Hypertext Markup Language (HTML) and contain text, graphics, audio, video and software.
SQL Reporting Services Overview SSRS includes all the development and management pieces necessary to publish end user reports in  HTML  PDF 
CGI Programming: Part 1. What is CGI? CGI = Common Gateway Interface Provides a standardized way for web browsers to: –Call programs on a server. –Pass.
Christopher M. Pascucci Basic Structural Concepts of.NET Browser – Server Interaction.
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Beginning Active Server Pages Barry Sosinsky Valda Hilley Programming.
8 Copyright © 2004, Oracle. All rights reserved. Creating LOVs and Editors.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Microsoft ASP.NET: An Overview of Caching Holly Mazerolle Developer Support Engineer Microsoft Developer Support Microsoft Corporation.
Server-side Scripting Powering the webs favourite services.
About Dynamic Sites (Front End / Back End Implementations) by Janssen & Associates Affordable Website Solutions for Individuals and Small Businesses.
IT533 Lectures Session Management in ASP.NET. Session Tracking 2 Personalization Personalization makes it possible for e-businesses to communicate effectively.
1 PHP and MySQL. 2 Topics  Querying Data with PHP  User-Driven Querying  Writing Data with PHP and MySQL PHP and MySQL.
Advanced Web Forms with Databases Programming Right from the Start with Visual Basic.NET 1/e 13.
Microsoft ASP.NET: An Overview of Caching. 2 Overview  Introduction to ASP.NET caching  Output caching  Data caching  Difference between Data Caching.
State Management. What is State management Why State management ViewState QueryString Cookies.
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
2 Copyright © 2004, Oracle. All rights reserved. Running a Forms Developer Application.
Management Information Systems MS Access MS Access is an application software that facilitates us to create Database Management Systems (DBMS)
INDIANAUNIVERSITYINDIANAUNIVERSITY OneStart page types  Tab – pages across the top, immutable  Section – pages down the left  Subsection – pages under.
PHP and MySQL CS How Web Site Architectures Work  User’s browser sends HTTP request.  The request may be a form where the action is to call PHP.
Lecture 8 – Cookies & Sessions SFDV3011 – Advanced Web Development 1.
Introduction to JavaScript 41 Introduction to Programming the WWW I CMSC Winter 2004 Lecture 17.
System Initialization 1)User starts application. 2)Client loads settings. 3)Client loads contact address book. 4)Client displays contact list. 5)Client.
Caching Chapter 12. Caching For high-performance apps Caching: storing frequently-used items in memory –Accessed more quickly Cached Web Form bypasses:
_______________________________________________________________________________________________________________ E-Commerce: Fundamentals and Applications1.
Chapter 6 Server-side Programming: Java Servlets
MS Access 2007 Management Information Systems 1. Overview 2  What is MS Access?  Access Terminology  Access Window  Database Window  Create New Database.
Christopher M. Pascucci Basic Structural Concepts of.NET Managing State & Scope.
ITCS373: Internet Technology Lecture 5: More HTML.
CSC 2720 Building Web Applications Server-side Scripting with PHP.
Creating PHPs to Insert, Update, and Delete Data CS 320.
STATE MANAGEMENT.  Web Applications are based on stateless HTTP protocol which does not retain any information about user requests  The concept of state.
Database Handling, Sessions, and AJAX. Post Back ASP.NET Functionality The IsPostBack method in ASP.NET is similar to the BlackBerry.refresh method –IsPostBack.
Creating Web Page Forms. Introducing Web Forms Web forms collect information from users Web forms include different control elements including: –Input.
® IBM Software Group © 2007 IBM Corporation Best Practices for Session Management
Java server pages. A JSP file basically contains HTML, but with embedded JSP tags with snippets of Java code inside them. A JSP file basically contains.
1 HTML Forms
Server-side Programming The combination of –HTML –JavaScript –DOM is sometimes referred to as Dynamic HTML (DHTML) Web pages that include scripting are.
ASP (Active Server Pages) by Bülent & Resul. Presentation Outline Introduction What is an ASP file? How does ASP work? What can ASP do? Differences Between.
ASP. What is ASP? ASP stands for Active Server Pages ASP is a Microsoft Technology ASP is a program that runs inside IIS IIS stands for Internet Information.
Virtual techdays INDIA │ 9-11 February 2011 Caching Enhancement in ASP.NET 4.0 Abhijit Jana │ Consultant, Microsoft
27.1 Chapter 27 WWW and HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Internet Applications (Cont’d) Basic Internet Applications – World Wide Web (WWW) Browser Architecture Static Documents Dynamic Documents Active Documents.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
ASP (COMPONENTS) Active Server Pages (cont..) 1. global.asa file The Global.asa file is an optional file that can contain declarations of objects, variables,
Creating Web Page Forms COE 201- Computer Proficiency.
1 State and Session Management HTTP is a stateless protocol – it has no memory of prior connections and cannot distinguish one request from another. The.
Advance Caching Techniques Keen Haynes MKAD SCCFUG Winter 2002 Conference.
ITM © Port,Kazman 1 ITM 352 Cookies. ITM © Port,Kazman 2 Problem… r How do you identify a particular user when they visit your site (or any.
Session, TempData, Cache Andres Käver, IT Kolledž
CHAPTER 7 LESSON C Creating Database Reports. Lesson C Objectives  Display image data in a report  Manually create queries and data links  Create summary.
XP New Perspectives on Macromedia Dreamweaver MX 2004 Tutorial 5 1 Adding Shared Site Elements.
27.1 Chapter 27 WWW and HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
2 Copyright © 2004, Oracle. All rights reserved. Running a Forms Developer Application.
Introduction to ASP.NET, Second Edition2 Chapter Objectives.
111 State Management Beginning ASP.NET in C# and VB Chapter 4 Pages
Running a Forms Developer Application
Caching Data in ASP.NET MVC
Chapter 19 PHP Part III Credits: Parts of the slides are based on slides created by textbook authors, P.J. Deitel and H. M. Deitel by Prentice Hall ©
ASP.NET Caching.
Introducing Forms.
Active server pages (ASP.NET)
Caching.
Presentation transcript:

ASP.NET Caching - Pradeepa Chandramohan

What is Caching? Storing data in memory for quick access. In Web Application environment, data that is cached is usually, commonly displayed database values. Repeated database calls are avoided. Demand on Web server’s and database server’s system resources are decreased. Increases performance by keeping frequently accessed data in memory.

Types of Caching Output Caching Fragment Caching Data Caching Time based Caching

Output Caching Also known as Page level Caching. Implementation is through an Output Cache Engine. Each time an ASP.NET page request comes in, the engine checks for a cached output entry. If found, this cached HTML is sent as response, otherwise, the page is dynamically created and stored in the Output Cache Engine. Useful in cases of many static pages.

Output Caching Implementation By using the OutputCache page directive. Syntax is as shown below: Duration – number of seconds the HTML output of the Web page is held in Cache. VaryByParam – Specifies how the caching should be performed based on the query string supplied to the page.

Output Caching - Example Consider the following URL: Query String passed to the page is name=John&newsid=12 Changing the VaryByParam attribute: Page will be cached according to the Name key. Consider the following two URLs Second page will be from cache (Cache will be refreshed only if the Name value changes)

Output Caching – Example (Contd..) Consider the following two URLs: http: //localhost/Caching/WebForm1.aspx?name=John&newsid=45 For the page to be regenerated, Name and NewsID keys have to be changed. This causes the second page to be refreshed. Equivalent to using a *, which means change in any key would regenerate the page. If the page has to be cached regardless of query string ‘none’ can be used.

Fragment Caching Caches regions of the page content. More powerful than Output Caching. This technique separates portions of a page that takes more time to create (such as database queries) from other parts of the page. The part of the page that requires less system resources can be generated dynamically for each request.

Fragment Caching - Example Consider a Web Application that displays the news titles in a Combo Box. The dataset containing the news is cached in order to minimize the number of times the application wants to connect to the SQL server to retrieve the news.

Fragment Caching – Example (Contd..) First time the page loads, user clicks on the Get News button to get the news from the SQL Server. We assume that the news changes daily. Page is refreshed each time the date changes. The cached version is displayed to all the users visiting the page on the same day.

Data Caching Storing data in memory for quick access. Items in the data cache will be evicted from memory, if memory becomes scarce. While adding items to a data cache, the duration of how long it can persist can be specified.

Data Caching - Implementation.NET data caching API is comprised of two classes in the System.Web.Caching namespace. The first class (Cache) is used to add and remove items from the data cache. The second class (Cache dependency) is used to assign a cache dependency to an item in the data cache. To add an item: Cache[“key”] = value; This adds the item value to the data cache with the key key. Key is used to reference the item at some later point.

Data Caching – Implementation (Contd..) To extract the value inserted above: value = Cache.Get(“Key”) To remove item from the cache: Cache.Remove(“Key”)

Time based Caching Caching based on time i.e. the data is available only for a certain period of time. Two ways to use: - Absolute Expiration - Sliding Expiration Absolute Expiration – Cache is set to expire on a particular date and time. Sliding Expiration – Cache is set to expire after certain period of inactivity.

Time based Caching - Implementation Absolute Expiration Cache.Insert(“News”,ds,null,DateTime.Now.AddMinutes(2),Cache.NoS lidingExpiration) The cache is set to expire exactly two minutes after the user has retrieved the data. Sliding Expiration Cache.Insert(“News”,ds,null,Cache.NoAbsoluteExpiration,TimeSpan.Fr omMinutes(1)) This causes the cache to be cleared if the user does not reload the page within one minute.

Use Caching Sparingly Caching has to be used sparingly. Takes up valuable system resources and eats up available memory. When server runs out of memory, contents of cache will be evicted. Eviction will be based on the priority of the data in the cache which can be set as shown: Cache.Insert(“News”,ds,null,Cache.NoAbsoluteExpiration,TimeSpan.Fr omMinutes(1),System.Web.Caching.CacheItemPriority.High,null) There are seven levels of priority: NotRemovable, High, AboveNormal, Default, Normal, BelowNormal, Low.

Conclusion Effective way of increasing performance. Minimizes the use of server resources. Choosing the appropriate level for caching data is important to balance caching versus memory usage. Most effective strategy in Web Application – Cache data only when necessary.

THANK YOU