Backported caching changes.