Cache template instantiation