Only cache template digests if !config.cache_template_loading

Since ActionView::Resolver.caching is set to the same value as config.cache_template_loading
only cache template digests if config.cache_template_loading is not falsy.

Fixes issues #10752 and #10791