Add caching to templates