optimize xtemplate by cache