There has been no randomised controlled studies into caffeine and dementia. Some small, unrandomised studies have found it to have a protective affect but, they are now sufficient to definitively prove a link.
https://www.alzheimers.org.uk/info/20010/risk_factors_and_prevention/145/caffeine