The other day reader Marni dropped a line asking whether or not her mostly unopened spice rack she received four years ago was still good. I started to respond to her, when I realized that she's probably not the only one wondering how long spices last.
First of all, spices don't necessarily "go bad." Those spices you've got stored in the back of the cabinet won't harm you, however, they do lose their potency and flavor. As a general rule, most ground herbs and spices will retain their flavor for about a year and three years for whole spices (whole nutmeg, cinnamon sticks, etc). However you'll find the best potency in the first three to four months. If sealed and unopened, ground spices may last two years. A good trick is to write the date of your purchase on the spices and toss them out a year after opening and two if unopened.
Another important factor in a spice's life is storage. Spices need to be stored in a cool, dark place away from heat and moisture. The spices you've got in the fancy glass jars on the kitchen counter (you know, the ones that get all that sunlight) are going to have an even shorter lifespan. The heat and light will suck the flavor out faster than you realize. The refrigerator is also not a great place for storage as the humidity can harm the spices as well.
And although most spices won't hurt you when they're old, seeds such as sesame and poppy can go rancid, so if you're unsure of them, toss them out!