Implement template caching.