decouple template and layout caching