Last hook to be called after entity save? Of the various hooks called during the entity save process, which is the very last to be called?

Is there a way to trigger an event after the entity has been created, after all fields have been saved, after caches updated, etc? So that, when a user saves the update form, this action is the very last thing to happen before the redirect page is loaded? 

If it's not strictly part of the save process, that's fine. What matters is: it's called after everything to do with an entity being saved. If there's a way of hooking some form function and reliably identifying from the data in there that a save process has been completed, or defining some callback, that's fine by me.

(context: I've got a problem where field caches are being created that caused newly created nodes, and other fieldable entity types, to load as if they are blank and as if they have no field data - but all attempts so far using cache_get and cache_clear_all don't find the cache - it's being created late in the process. So I'm looking for the latest possible hook which will definitely get it)

(Relevant info: hook_entity_postsave doesn't exist, and is one of those core issues that got stuck months and months ago)
The various wrapper functions (node_save(), user_save(), etc.) are responsible for resetting the entity cache after the save method has been invoked on an entity controller.

If you take the user_save() function as an example, this cache reset happens after the function invokes the various entity hooks (same goes for node_load())

That in mind, I think the question then becomes "What is the last hook to be called during an entity save"?...and the answer is hook_entity_update() / hook_entity_insert(). But, they are called before the cache is reset (for obvious reasons).

The entity_save() method just invokes the save handler for that particular entity type, and doesn't invoke any hooks of its own, so really your only options are:


Roll your own entity controller for the various entities you need to intercept, changing the save() method to invoke a hook after the cache has been cleared.
Hack/patch the existing entity controllers with the same code.


Neither are particularly attractive options but unless there's a solution available at a higher level that I'm not seeing, I don't think you've got much choice.