Another important approach is to build up your cognitive reserve. Evidence exists that people who read more, socially interact more, play music, dance, and stay physically active can delay the onset of dementia by years.
Eating right (minimize processed foods and sugars, focus on raw foods, vegetables, fruit, minimal chemicals) is also associated with better memory.
Finally, getting a full 8 hours of sleep is associated with good brain health. The brain appears to require about 7-8 hours to fully process the day's knowledge and build it into long term memory structures. If you cheat yourself and get 4-6 hours, most likely your brain simply won't have a chance to build those neural structures to capture long term memories.
Probably the type of people who read Hacker News are doing a lot of this stuff already; just working in a technical field that forces you to think all day is very helpful. Exercise and diet are probably the areas that techies notoriously neglect, but that's perhaps more a previous generation than the more health-conscious folks of today's workplace.