Dynamic Page Cache not working for my controller? I have a module that defines route /x and assigns it the controller ViewNodes::show. This takes no parameters and the show method simply returns a nearly blank render array:

[
'#theme' =&gt; 'view_nodes', 
'#cache' =&gt; ['tags' =&gt; ['node_list'], 'max-age' =&gt; Cache::PERMANENT, 'bin' =&gt; 'render'], 
'#pre_render' =&gt; [[$this, 'buildNodeListView']]
];


The buildNodeListView then takes care of doing all the expensive logic and SQL queries to build the array. This all works fine and the page displays as expected, but devel's WebProfiler shows the SQL queries for building the render array are still being executed even when they should have been cached. This suggests buildNodeListView is always being called, which means #pre_render is always being called, which means the render array is always a miss. Am I mistaken here?

The route shows up under "bin dynamic_page_cache" and is always marked as MISS. And in the HTTP headers, there's always X-DRUPAL-DYNAMIC-CACHE: UNCACHEABLE

Is there something I'm doing wrong, or things I should check to further debug this? My settings.local.php has 

//$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.null';


and 

 //$settings['cache']['bins']['render'] = 'cache.backend.null';


They're both commented out so the caching should be enabled. The Dynamic Page Cache module is also enabled. And my routes do not have the "no_cache" option.
You need cache keys

'#cache' =&gt; ['keys' =&gt; ['key1', 'key2', ...], ...]


and this is not the dynamic page cache, it is the standard render cache which will take care of this.