Add cache functionality for compiling templates