What's the best way to improve bone density when one's approaching middle age?

Good nutrition. There is no way to improve bone density when approaching middle age. Maintaining bone density is done by good nutrition including adequate calcium and vitamin d. Weightbearing is also helpful in preventing bone loss.
Vitamin D. Until a woman reaches menopause, her bone metabolism is capable of building itself up with satisfactory diet including calcium-rich foods, adequate (but not excessive) vitamin d levels, and vigorous resistance exercises. After menopause, these measures have much less impact. Don't wait until them to get your bones ready for the second half of life.