add directive and cache template