showing cached page on error with cfcache

102 Views Asked by At

I am curious if there is a way to do this, basically I have a set of API calls that are cached with the dependson flag. Now this generally works as a way to expire cache for the client when they make an update, I basically use this as a cache key, if they update something on the back-end then we know to expire the cache.

Now this works great 99% of the time but recently I had an issue with a poor performing query and it caused the DB to slow way down, essentially causing the query for the cache key to time-out, well the timeout cased the entire page to basically 'catch' and display a null object. This is problomatic because now users were getting 'blank' objects.

My question is, is there a way to, on-error just show the previous cached page and not try and update it?

1

There are 1 best solutions below

0
On

You could just update the cache after you know it works so:

<cfsavecontent variable="content">
<cfoutput>
<!--- create your content here. --->
</cfoutput>
</cfsavecontent>

<!--- Then write the content to cache. --->
My Caching code ..... goes here
<cfoutput>#content#</cfoutput>