Just how long do spices stay good? Hmmmmmm. Good question. I bet a lot of you don't realize that spices really don't have a shelf life. Most if kept in dark, air tight containers can stay good for a looooong time. Yes, that's right, a long time. Some people think that you have to throw away spices after six months or so. Not true. The government guideline is 4 years for whole and 2 years for ground. However, sometimes even the best spices die young and you need to use your sniffer to check the potency. Yep, you nose will tell you if a spice is still potent and worth using.
Spices do lose their potency. As do dried herbs. However, just because a dried herb looks gray and almost colorless, doesn't mean it isn't good. Press a bit into the palm of your hand. Rub it around, does it still have a good aroma? If so, use it!
Some things to keep in mind, however. When using spices, don't shake the container over a steaming pot. This allows moisture to settle into the jar and that begins deterioration. It's not a good practice to shake over your pot because you could use a bit too much and ruin a perfectly good dish just by the tip of your hand. Measure your spices into those cute little bowls, or even a plate prior to getting your cooking started. Then you have them when you need them and there is not a concern of too much to quickly in a "shake".
Keep in mind also, that dried herbs are always more potent than fresh. Be careful with that dried basil, it can really spoil a palate if used incorrectly. Herbs are best fresh, but not many of us live in climates where you can have them fresh all year long, so a good supply of dried herbs is usually best for times of shortage.
Whole spices keep their potency longer than ground spices. When, and if possible, purchase whole spices and grind what you need when you need it. Keeping them in sealed containers and a dark place is a good rule of thumb for all spices, whole or ground.
Heat is also a factor when storing spices. The cooler the area for storage the better. Heat is another reason you don't shake the container over the pot, the heat does damage more than you realize.
Another thing with ground spices to keep in mind is that the spice berry, for lack of a better term, is made up of several layers that give body and fullness to the spice. Those layers can lose potency separately. Some parts will be good as others are fading and the full body of flavors will decline.