Remove cache if build fails

rename tryFlushCache, since calling the function doesn't guarantee flushing of cache and it doesn't return an error if it fails