Add caching to template_is_active.