How can I clear a client-side or server-side cache that was created by the <cfcache> tag?

The <cfcache> tag provides an easy way to clear the contents of a <cfcache> cached page before the cached page would time out on its own. By using the action="flush" attribute, you can flush the contents of the cached page so that it can be recached with current data. The simplest way to do this is to run the following code:

<cfcache action = "flush">

The above line of code would clear all cached files in the same directory as the template you called it from. If you need more control over flushing a <cfcache> cached page, you can use the following optional attributes: directory and expireURL.

The directory attribute lets you specify the directory that contains the cached files you wish to clear.

The expireURL attribute is a URL reference that you can use to choose what specific cache files will be deleted. You can use an * character as a wildcard. Some sample URL's would be "foo.cfm?Key=1" or "foo.cfm?*". The first sample would only delete the cached copy of foo.cfm with the URL parameter key = to 1, where as the second sample would delete the cached copy of any foo.cfm page with any URL parameters.

This question was written by Jeremy Petersen
It was last updated on March 7, 2006.




comments powered by Disqus