How would you design caching and offline-first persistence for large chat histories on device at xAI?