Fix message rendering cache behavior

Fixed the message rendering cache to use content strings as keys instead of hash values, and now returns copies of cached results to prevent unintended mutations. This ensures rendered messages are properly cached and reused without side effects.