Use combined cache for templating module vars

Fixes #6901