Clearing cache at the right place