ASP Template Caching (IIS 6.0)
ASP processes the templates or template files that contain ASP scripts. ASP stores these templates in a template cache and then serves the cached templates for subsequent client requests. Caching ASP templates enhances performance and scalability, because cached templates are not compiled each time they are called.
The ASP template cache uses a least-recently-used algorithm for determining which templates are cached. This means that if the cache is full, the template that has been in the cache and has not been requested for the longest amount of time is replaced by the next template to enter the cache. Every time a new template is added to the cache, the template goes to the beginning of the cache. The ASP template cache stores up to 500 templates by default (as determined by the AspScriptFileCacheSize metabase property). Templates are moved to the beginning of the cache when they are requested. In the case where the 501st template is bumped from the cache, the template is written to disk. By default, the ASP disk cache can hold 2,000 templates (as determined by the AspMaxDiskTemplateCacheFiles metabase property). If a template in the disk cache is referenced, the template is moved back to the ASP template cache.
In worker process isolation mode, AspScriptFileCacheSize and AspMaxDiskTemplateCacheFiles are global settings, which means they apply to all ASP pages on the Web server. (They are process-level settings in IIS 5.0 isolation mode.) ASP pages can contain #include files and these #includefiles can make the ASP files very large. The default 500-file limit established by the ASP template cache applies only to ASP pages and not #include files. However, ASP files that contain #include files can grow large enough to cause memory shortages and errors. ASP will flush the ASP template cache if IIS runs out of memory. If the ASP template cache is flushed, each subsequent request to an ASP page will need to be recompiled before it is cached again. In these situations, you might see ASP queuing. If you display the Active Server Pages\In Memory Templates Cached counter in System Monitor and see spikes followed by a severe reduction in the number of cached templates, your ASP pages might be too big. This could cause your system to run out of memory, flush the cache, recompile, and then run out of memory again. To remedy this situation, reduce the size of the ASP template cache to a number less than 500. Table 7.6 lists the preferred or ideal values for ASP template cache counters. For more information about IIS 6.0 counters, see the Performance Counters Reference.
The ASP disk cache begins caching files into a directory when the ASP memory cache is full. Furthermore, a file has to be requested at least twice before it becomes a candidate for the ASP disk cache. The corresponding metabase property, AspMaxDiskTemplateCacheFiles, specifies the maximum number of compiled ASP templates that can be stored. AspDiskTemplateCacheDirectory contains the name of the directory that ASP uses to store compiled ASP templates to disk after overflow of the in-memory cache.
In order for disk caching to work, ASP needs a properly configured disk cache directory in which to store the compiled ASP files. This means that the Administrators and IIS_WPG groups have Read/Write and Delete permission on the disk cache directory, and the disk cache directory is a local directory on the Web server.
The default location of the disk cache is systemroot\System32\inetsrv\ASP Compiled Templates. In worker process isolation mode, subdirectories under the disk cache directory are created for each application pool. In IIS 5.0 isolation mode, the default disk cache directory is windir\system32\inetsrv\ASP Compiled Templates.
For information about changing the settings for caching ASP templates and creating an ASP disk cache directory, see Configuring ASP Template Caching.