Invalidating cached data

Phil Karlton, while working at Netscape, once said:

"There are only two hard things in Computer Science: cache invalidation and naming things."

The joke is funny because there is truth to it. Data in a cache may become stale if it is changed after it was placed in the cache. Cache invalidation is the process of replacing or removing cached items. We must ensure that we are handling cached data properly so that stale data is replaced or removed. It may also be necessary to remove cached items if the cache becomes full.