Automatically generate cache if needed