resource metadata state caching

barely tested.