Move caching of compilation results to its own layer.

This will allow only creating the razor compilation when really needed, with the right lifetime.