Fix caching so it is properly cleared between top level requests.
Split up code of embed to make cache logic clearer.