Caffeine has well-known short-term stimulating effects on central nervous system, but the long-term impacts on cognition have been less clear. Dementia and Alzheimer's disease (AD) are rapidly increasing public health problems in ageing populations and at the moment curative treatment is lacking. Thus, the putative protective effects of caffeine against dementia/AD are of great interest. Here, we discuss findings from the longitudinal epidemiological studies about caffeine/coffee/tea and dementia/AD/cognitive functioning with a special emphasis on our recent results from the Cardiovascular Risk Factors, Aging and Dementia (CAIDE) study. The findings of the previous studies are somewhat inconsistent, but most studies (3 out of 5) support coffee's favorable effects against cognitive decline, dementia or AD. In addition, two studies had combined coffee and tea drinking and indicated some positive effects on cognitive functioning. For tea drinking, protective effects against cognitive decline/dementia are still less evident. In the CAIDE study, coffee drinking of 3-5 cups per day at midlife was associated with a decreased risk of dementia/AD by about 65% at late-life. In conclusion, coffee drinking may be associated with a decreased risk of dementia/AD. This may be mediated by caffeine and/or other mechanisms like antioxidant capacity and increased insulin sensitivity. This finding might open possibilities for prevention or postponing the onset of dementia/AD.