Issue #1786490 by Berdir, amateescu, damiankloip, dawehner: Add caching to the state system.