Fix undefined offset by caching last metadata.