handle template caching