Caching failure

From Free net encyclopedia

Revision as of 20:33, 4 December 2005; view current revision
←Older revision | Newer revision→

Caching failure is a type of software bug, in which a program keeps results (caching) indicating a failure even after the failure has been corrected. (That is, the term refers to caching, or remembering, a condition of failure - rather than a failure of caching.)

This occurs when out-of-date error indicator prevents a program from working correctly. An error occurs at some point, and a flag is set to indicate the error. The user takes the necessary steps to fix the error, but the error flag is not updated, so the program still does not work.

Only when failure is very expensive and the error condition arises automatically without user guidance should failure be cached. Caching failure creates a situation where the user is unable to isolate the cause of the failure: despite fixing everything he can think of, it still refuses to work! When failure is cached, the system should give a clear indication of what must be done to clear the flag so the system will try again, in addition to a description of the cause of the error.

An example: Consider a Web browser which attempts to load a page while the network is unavailable. The browser will receive an error code indicating the problem, and may display this error message to the user in place of the requested page. However, it is incorrect for the browser to place the error message in the page cache, as this would lead it to display the error again when the user tries to load the same page - even after the network is back up. The error message must not be cached under the page's URL; until the browser is able to successfully load the page, whenever the user tries to load the page, the browser must make a new attempt.

Caching failure is an example of an anti-pattern.

There are cases where failure-like states must be cached. For instance, DNS requires that caching nameservers remember negative responses as well as positive ones. If an authoritative nameserver returns a negative response, indicating that a name does not exist, this is cached. The negative response may be perceived as a failure at the application level; however, to the nameserver caching it, it is not a failure. The cache times for negative and positive caching may be tuned independently.

Reference