Cache purging should be also moved to if block