Spices, both whole and ground, do have a shelf life, although it is linger than some people might imagine. Spices do not go bad in the sense of becoming rancid or spoiled, but they do lose potency and complex layers of flavor. When spices lose their power, they should be discarded. Ideally, try to purchase spices whole and grind them, as you do not know how long ground spices have been stored in a warehouse or store.
Whole spices will keep the longest, because they have not been cracked or ground, exposing the volatile compounds which make up their flavor to the air. They can last up to four years in an airtight container in a cool, dry place, and will keep even better in the dark. Extremely strong spices such as whole cloves, cinnamon, and pepper may last even longer. You can tell that whole spices are too old to use when they have lost their aroma.
Ground spices have a shorter shelf life, usually between two and three years. They should also be stored in airtight containers in a cool, dry place. To determine whether or not ground spices are still usuable, gently shake the container with the cap on. Remove the cap after a moment and smell the container, to see if the rich smell of the spice is still present. If ground spices have declined in quality, you can use more of them in a recipe, with care, or toast them to refresh the flavor. To toast ground soices, use a cast iron skillet or a heavy pot over medium heat, tossing the spices periodically to distribute the heat, and use them immediately.
Dried herbs keep for less time, because they are more delicate. Most culinary herbs last between one and three years. Test culinary herbs by crushing them lightly in your hand. If the herbs still smell, they are good, even if the color has changed. If no odor rises after crushing, discard them.
You can prolong the life of your spices by storing and handling them well. Spices do not do well in extreme heat; so do not store them directly above the stove. They also keep poorly in the cold, so freezing them is not advisable. When using spices in cooking, pre-measure them, rather than pouring them over a hot dish. The steam will damage the spices, and if your hand slips, you may ruin the dish. Also always use clean, dry measuring implements when dipping into containers of spices.