AS pointed out by review by Sensio, current code will lead to new cache generated every time the content returned from legacy is different.
The code causing the issue:
Two solutions are available:
- Having a physical template and use it directly.
- Changing the template above to display the content as a twig variable: