ASP template cache does not recognize script updates on a cluster resource (239703)



The information in this article applies to:

  • Microsoft Internet Information Server 4.0
  • Microsoft Internet Information Server 5.0

This article was previously published under Q239703
Important This article contains information about how to modify the registry. Make sure to back up the registry before you modify it. Make sure that you know how to restore the registry if a problem occurs. For more information about how to back up, restore, and modify the registry, click the following article number to view the article in the Microsoft Knowledge Base:

256986 Description of the Microsoft Windows registry

SYMPTOMS

Active Server Pages (ASP) may not recognize or return updated ASP script files when Internet Information Server (IIS) is installed and running on Microsoft Cluster Server.

CAUSE

The ASP template cache is never cleared or updated after a required Cluster Server disk resource is taken off line due to a manual (test) failover. In a usual cluster environment, a disk device failover should only occur after a node has failed (crashed). This problem does not occur in a production cluster environment, in which the device failover occurs because the node has actually failed, so that applications and system services are reset by the system restart.

The ASP template cache tracks directory changes to determine when a cached script file in the directory has been updated, and needs to be purged from the cache and reloaded. In a cluster environment, tracking directory changes requires more caution because Cluster Server allows a volume (disk mounted by a file system) to be dismounted while applications are running with open handles to the volume, which allows the device to be taken off line immediately. When a volume is dismounted, any open handles to that volume are no longer valid for reading, writing, or tracking directory change notifications.

Cluster-aware applications can request notifications from Cluster Server when a volume has been dismounted; however, ASP is not cluster aware, so it is not notified to clear the template cache after a device is taken offline. Because ASP can no longer detect changes to script files in the monitored directory, it never purges the template cache, and subsequent changes to script files on the cluster device are not reflected until IIS is stopped and restarted.

WORKAROUND

Warning Serious problems might occur if you modify the registry incorrectly by using Registry Editor or by using another method. These problems might require that you reinstall your operating system. Microsoft cannot guarantee that these problems can be solved. Modify the registry at your own risk.

To work around this problem, disable ASP template caching, and then use a script that unloads the IIS application when a required device is offline.

To disable ASP template caching, modify the DisableMemoryCache registry entry. To do this, follow these steps:
  1. Click Start, click Run, type regedit, and then click OK.
  2. Locate and then click the following registry subkey:

    HEKY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\InetInfo\Parameters

  3. Right-click Parameters, point to New, and then click DWORD Value.
  4. In the New Value #1 box, type DisableMemoryCache, and then press ENTER.
  5. Right-click DisableMemoryCache, and then click Modify.
  6. In the Value data box, type 1, and then click OK.
  7. Quit Registry Editor, and then restart the computer.
This workaround allows reliable use of the ASP cache with a script that flushes the cache when the site changes states. The script accomplishes this task by using the Active Directory Service Interfaces (ADSI) AppUnload method for the affected site when it is brought back online by cluster, which effectively flushes the ASP cache.

The following is a sample script that flushes the cache for the root site:
' unloadapps.vbs sample
const ForReading = 1,_ 
ForAppending = 8
const Path = "C:\unloadapps"

Sub LogError(ByVal FileName, ByVal Err, ByVal Detail)

DIM a
Dim fileio
Dim Seperator

on error resume next
Seperator = " "

set fileio = CreateObject("Scripting.FileSystemObject")
if fileio.FolderExists(Path) = FALSE then
fileio.CreateFolder(Path)
end if
Set a = fileio.OpenTextFile(Path + "\" + FileName, ForAppending, TRUE)
a.Write("Time: " + Time() + Seperator)
a.Write("Error: " + Hex(Err.Number) + Seperator)
a.Write("Description: " + Err.Description + Seperator)
a.WriteLine("Detail: " + Detail + Seperator)
a.Close
set a = nothing
set fileio = nothing


End Sub

Sub Main()


Dim PathList
Dim Path
Dim FileName

on error resume next
IIsObjectPath = "IIS://Localhost"
Set IIsObject = GetObject (IIsObjectPath)
PathList = IIsObject.GetDataPaths ("appwamclsid", IIS_DATA_INHERIT)
FileName = Replace(Date(),"/","-") + " unloadapps.log"
For Each Path in PathList


Set IISObject2 = GetObject (Path)
If Path = "IIS://Localhost/W3SVC" then
else

IISObject2.AppUnload()
if err.number > 0 then

LogError FileName,err,"Failed to unload " + Path
err.clear

else

LogError FileName,err,"Successfully unloaded application " + Path

end if

end if

Next

End Sub

Main
				
The script must be added to the IIS cluster group as a process that is dependent on the site. To do this, perform the following steps:
  1. Copy the Unloadapps.vbs file to the c:\Scripts\Unloadapps.vbs directory on all cluster nodes.
  2. In the Cluster Administrator, create a new generic application resource in the IIS cluster group named Flush ASP Cache, and then click Next.
  3. Allow all nodes to be possible owners, and then click Next.
  4. Place a resource dependency on the IIS server resource, and then click Next.
  5. From a command line, type cmd /k cscript c:\scripts\unloadapps.vbs. (Note that this is different from the previous instructions, so that the process stays open until the next failover and does not get reported as resource failed.)
  6. Set the current directory to c:\scripts.
  7. Do not select Allow application to interact with desktop.
  8. Click Next, and then click Finish.
  9. Test failover to make sure the cache is flushed as expected.

Modification Type:MajorLast Reviewed:2/9/2006
Keywords:kbfix kbprb KB239703 kbAudDeveloper