handle the cached_items counter in a more correct and reliable way