In general, either a drink (frequently containing alcohol) consumed prior to sleeping, or an invitation to sleep in another person's (usually of the opposite gender) home or dwelling, usually after a date. Note that this frequently is for the purpose of sex, however, under some circumstances, this can be quite innocent.
As a drink, nightcaps are consumed to induce drowsiness and have a calming effect. Traditionally, nightcaps are alcoholic, such as martinis, or sometimes straight spirit, especially vodka. However, in modern times, non-alcoholic nightcaps have become more common. These are, unlike their alcoholic counterparts, usually warm beverages. Good examples are tea, especially tisanes (aka herbal teas), which contain no caffeine, milk (served either warm or chilled), or sometimes simply sparkling water (such as Perrier).
An antiquated meaning of nightcap is quite literal: a hat or other garment used to adorn one's head at night.