APGen Documentation Previous Topic: CachedFile Object Next Topic: CachedFile.MonitoringFileChanges Parent Topic: CachedFile Object    CachedFile Object
CachedFile.Contents
See Also:

Returns the contents of the cached file as a string.

Syntax

VBScript:

sContents = cachedFile.Contents

JScript:

sContents = cachedFile.Contents;

Object

cachedFile A CachedFile object.

Return Value

sContents A string containing the contents of the cached file.

Notes

This property behaves the same regardless of whether a file handle is cached or the file contents are cached in memory.

This example performs string replacement on a file fragment before writing its contents to the Response object:

' Retrieve the CachedFile object from the Cache
Dim sFragPath, cf, sFrag

' Use a product page fragment
sFragPath = "products/prod" & id & ".htm"

If Cache.Exists(sFragPath) Then

     ' Retrieve the CachedFile object from the Cache
     Set cf = Cache(sFragPath)
    
     ' Replace tags within the fragment with the user id
     sFrag = Replace(cf.Contents, "<$userid$>", sUserId)

     ' Write the page fragment to the ASP Response
     Response.Write sFrag

Else
     ' .. error handling
End If