Page 277 - DCAP312_WEB_TECHNOLOGIES_II
P. 277

Unit 14: Debugging and Optimization



               2.  In the Machine.config file, locate the compilation element. Debugging is enabled when   Notes
                 the debug attribute in the compilation element is set to true.
               3.  If the debug attribute is true, change the debug attribute to false.
               4.  The following code sample shows the compilation element with debug set to false:
                  <compilation
                  debug= “false”
                  /  >
                  Save the Machine.config file.

            14.2 Optimizing Using Caching

            ASP.NET 3.5 intrinsic cache functionality has long been one of my favourite aspects of ASP.
            NET.  With  a  little  bit  of  planning  and  organization,  we  can  use  it  to  create  highly  scalable
            applications with robust fidelity. Optimization is the act of improving a method or design. In
            programming, optimization usually takes the form of increasing the speed of an algorithm, or
            reducing the resources it requires.
            Best ways are to optimize our use of the ASP.NET cache and what some of the tips are in regards
            to how to determine what should and should not go in the cache. Also, are there any rules of
            thumb for determining how long something should say in the cache?
            14.2.1 ASP.NET Caching Features

            The  ASP.NET  3.5 Cache  API  was  a revolutionary feature that provided  capabilities such  as
            declarative output caching, programmatic output caching, and invalidation of cached items when
            the contents of an XML file or another cached item change. Even though all these increased the
            performance of Web applications, ASP.NET 3.5 did not provide a mechanism for invalidating
            the data in a cache object when the data in a database changes. This much sought after feature
            will finally ship with ASP.NET 3.5 Apart from this, ASP.NET 3.5 will also provide functionalities
            to cache the output of a SqlDataSource control, which enable us to take advantage of caching
            without writing a single line of code.
            In ASP.NET 3.5, caching has improved in a couple of notable ways. Probably the most interesting
            improvement is the introduction of database-triggered cache invalidation. In ASP.NET 3.5, we
            can invalidate a cached item based on some pre-defined conditions, such as change in an XML
            file, change in another cache item, and so on. By using this feature, we can remove or invalidate
            an item from the cache when the data or another cached item changes. However, the ASP.NET
            3.5 Cache API does not allow us to invalidate an item in the cache when data in a SQL Server
            database changes, even though most applications require this capability. ASP.NET 3.5 addresses
            this by providing the database-triggered cache invalidation capability that allows us to ensure
            that items in the cache are kept up to date with the changes in the database.
            Another important caching feature in ASP.NET 3.5 is the ability to enable caching at the
            SqlDataSource level. The SqlDataSource control is designed to work with SQL Server, OLE DB,
            ODBC, and Oracle databases. As the name suggests, this control enables us to select, update,
            delete, and insert data using SQL commands. With the ability to set caching attributes at the
            SqlDataSource control level, we now have a finer level of control over the cached data.
            The ASP.NET 3.5 also provides a new control named Substitution, which we can use to inject
            dynamic  content  in  an  otherwise  cached  Web  page.  If  we  have  a  page  with  output-caching
            but still want to display dynamic content (that needs to be generated every time the page is
            requested), consider using the Substitution control.
            The following sections provide examples of the above features.

                                             LOVELY PROFESSIONAL UNIVERSITY                                   271
   272   273   274   275   276   277   278   279   280   281   282