WebGecko Home
Authoring and caching solutions for a better Web experience
SEARCHStart search

ASPCACHE FREQUENTLY ASKED QUESTIONS

If your questions are not answered here, use our support form to ask us a question.

Questions
  1. Can ASPCache be implemented without any recoding?
  2. What additional load does ASPCache bring to the server?
  3. Is it possible to cache page fragments without using APGen?
  4. Do you provide both sliding and absolute expiration parameters for cached items?
  5. When an item expires is it immediately removed?
  6. Does ASPCache have a persistence interface?
  7. How does key size affect performance as the cache grows in size?
  8. If we are running two applications on the Web server and we want to use ASPCache on each are they going to share the same cache?
  9. Can you suggest a way that ASPCache can be used to cache XSL files?
Answers

Can ASPCache be implemented without any recoding?

No, implementing ASPCache does require some recoding.  Data caching with ASPCache requires minimal conversion effort.  Output caching requires a bit more recoding, but the performance gains easily justify the effort.

To implement data caching with ASPCache, add the <OBJECT> tag to the global.asa file, and store or read data in the Cache object wherever you need it.  Conversion is very simple if you're currently caching data in the ASP Application object: Just search and replace "Application(" with "Cache(".

To implement whole page caching, we recommend using APGen.  APGen 2.0 includes an ASPToAPG utility that does conversion for you.

Page fragment caching with ASPCache does require recoding: The page fragment that you wish to cache needs to be moved to an APG script, and replaced with a call to ASPCache.WriteFile().  For more information, see Page Fragment Caching.

What additional load does ASPCache bring to the server?

ASPCache is a component, not an ISAPI filter - consequently ASPCache adds no load to most requests.  ISAPI filters add some load to every request, components only add load when they are called.

When an ASPCache method is called from an ASP page, there is some load, but the load is much less than other caching and collection components.  For performance numbers, see ASPCache Collection Performance.

Is it possible to cache page fragments without using APGen?

Yes, it is possible to cache page fragments without using APGen.  Page fragments are just files, so you can generate them any way you want.  You could use XMLHTTP to download the page fragment.  You could use the FSO (FileSystem Object) to write a page fragment file.  You can use XML and XSLT to generate page fragments.

However, APGen generally works best because it offers easier page authoring and maintenance (similar to ASP).  APGen was designed for scripted generation of Web pages and files, and will save you effort in all content generation tasks.

Do you provide both sliding and absolute expiration parameters for cached items?

ASPCache does not implement "sliding expiration".  ASPCache does offer absolute expiration.

However, a developer can effectively implement sliding expiration by setting the item's expiration every time it is accessed:

<%

// Do this every time the item is accessed
Cache.SetExpiration("key", 10000); // Make the item expire 10 seconds from now
value = Cache("key"); // Retrieve the value from the cache

%>

When an item expires is it immediately removed?

No, expired items are not immediately removed.  Though immediate removal might be nice in some cases, it would add too much overhead for most cases.

Items that have expired are removed in one of two ways:

a) When the background flush/expire thread runs (you can set how often it runs by setting FlushEnabled=True and FlushInterval=interval), any expired items are removed.  If the FlushInterval is long, items may not be removed for some time after they expire.  If FlushEnabled is False (the default), expired items are never removed by the background cleanup thread.  If you want prompt cleanup, set a short FlushInterval.  Since the cleanup thread is a lower priority thread, frequent cleanup won't slow down your ASP requests (though you may notice higher CPU usage, it's only using cycles that are unused by higher priority threads).

b) If an expired item is retrieved, set, or otherwise accessed, and the background thread has not yet removed the item, it is removed and the method acts like the expired item wasn't there.  This means that the item is removed at the first access after it has expired.

The background flush thread is disabled by default (to minimize overhead).  To enable background cleanup of expired and underused items, set FlushEnabled to True and FlushInterval to an appropriate interval for the application.

Does ASPCache have a persistence interface?

No.  We will implement persistence methods in ASPCache 2.0, including methods to persist and depersist to an XML string or XML file.  We will also implement auto-loading.

In the meantime, you can always iterate over the collection and save or restore its contents.  Iteration over an ASPCache object is efficient.

How does key size affect performance as the cache grows in size?

ASPCache performs a hash on the key before insertion, lookup, and removal.  The key is only scanned once per cache operation, so longer keys won't make much of a difference in overall performance.  Also, key size makes no incremental difference as the cache grows.

If we are running two applications on the Web server and we want to use ASPCache on each are they going to share the same cache?

No.  Each ASP application (with 1 global.asa file that instantiates an ASPCache object) can only access its own ASPCache(s).  An ASP application can instantiate multiple ASPCache objects, but other ASP applications won't be able to access them.

If you want to expose data in an ASPCache to other applications, one way is to write an ASP page that returns the cached data in XML.  The client can use the XMLHttpRequest component to retrieve the data.

Can you suggest a way that ASPCache can be used to cache XSL files?

If you're performing the XSLT transforms on the server, the best performing architecture is to run the transforms once, then cache the output in ASPCache, so the overhead of one transform is spread across multiple requests.  This is only viable if the XSLT output can be shared for multiple users.

If each user receives different output (the XML input changes for each user), then use the XSLTemplate object to cache the compiled XSLT document.  XSLTemplate objects can be stored in ASPCache.  This isn't as efficient as caching the output, but it's better than re-compiling the XSL during every request.

ASPCache can cache any COM object, but you should only cache FreeThreaded objects (like Msxml2.FreeThreadedDOMDocument and Msxml2.XSLTemplate).  When using XSLT, several types of data or objects can be cached: The XML data can be cached as a string; a parsed XML DOM object can be cached; the XSLTemplates can be cached; and/or the XSLT output can be cached.  Choose what to cache depending on what gives you the most savings.  Note that caching output is much more valuable than caching any of the other objects, because there is much less work required per request to convert the cached output to displayable page content.

As a rule, caching anything is useful if it saves the Web server work.  The more work that is saved, the more valuable caching is.  If after you cache the XSLT output, you find that you're still parsing the XML or XSLT documents pretty often, and they're not changing, then you can further improve efficiency by caching the XML DOM or XSLTemplate objects.




Home  |  Products  |  Community  |  Sales  |  Support  |  Company
Mailing List  |  Services  |  Press  |  Search  |  Privacy  |  Contact Us