Dried herbs/spices can be thought of and treated much like coffee beans.
Keep them in cool airtight containers in the dark. Only buy enough for a few months, many lose their potency by about 12 months or so. (It varies)
Avoid buying them from supermarkets and other big-box type stores. If you have a local asian supermarket, they probably sell a lot fresher and better quality stuff. If you don't have one, you might be able to order them online instead.
Grinding/roasting your own is better, but if that's too difficult a good asian supermarket will have pre-ground stuff that's also pretty good.
Like coffee beans, they lose their potency faster once ground.