Improving templayed support

(Forbes Lindesay)[https://github.com/ForbesLindesay] made questions about cache support and he helped me to improve it.

Thank you, Forbes. :)