Fix: check if entity cache enabled before using it