Currently, we clear query_cache in cache block finish, even if we may already have cache true.

This commit takes into account the last cache_enabled value, before clearing query_cache.
Merge pull request #11643 from vipulnsward/query_cache_clear

Fix QueryCache to work with nested blocks