fix local cache deleting at close (swift)