(Assuming you're referring to CD-R discs, instead of pressed CD-ROMs)
CD-R and DVD-R discs work by allowing you to write data to a thin coating of dye that is "burned" when exposed to a focused laser beam. Over time, the burned portions of the dye can "bleed" over to the unburned portions, making the disc no longer readable.
Based on these facts, we can derive some logical common-sense tips for storing burned CDs:
- Most importantly: Store them in a dark environment (such as a sealed booklet of CDs), so that any incident light can't burn the disc further over time. Take the CD out only when you need to read it.
- Store them in a cool environment to maximize the viscosity of the dye. But more importantly, store them in an environment with constant temperature, instead of variable temperature (to minimize expansion and contraction of the media).
- As for humidity, normal household humidity is fine. If you're worried about it, then put a desiccant packet into the case with the CDs.
- Store each CD in a sleeve that minimizes scratching and prevents dust from getting in. The commercial CD booklets do a good job with this (you know, those 100-pack CaseLogic cases). The key is to insert the CD into the booklet once, and only take it out when you need to read it. (Mess with it as little as possible)
- Store collections of CDs in a protective case that minimizes bending or any other mechanical stress. (i.e. store CD collections on top of other items, not vice versa)
- Store CDs so that they lie flat, instead of vertically, to minimize distortion of the dye due to gravity.
In the case of pressed CDs, their lifespan is an order of magnitude longer than CD-Rs, since they're literally metal with physical grooves in it. However, most of the above tips would still apply.
Edit: As Donald.McLean comments, err on the low end of the CDs' projected lifespan, and replace them at reasonable time intervals.
Another thing to keep in mind is that there's a high variability in the quality of CD/DVD-R media made by different manufacturers. Make sure to buy from a respected manufacturer.
Just a little personal experience: I recently tried reading some CD-Rs that I burned in 2003, and read them all without any problems. The only times I've had trouble reading CD-Rs were when the discs had visible scratches.
This answer on Server Fault might be useful for additional information. I personally wouldn't consider physical CD/DVDs as "long-term" backup solutions, as you still need to ensure the integrity of them every few years - and in the case they need to be re-made, what's the likelyhood they'll even make CDs/DVDs in 10 years? It's hard enough to find a new computer now that even comes with a CD/DVD drive (and certainly, I didn't bother putting one in my new desktop build). – Breakthrough – 2013-03-18T18:05:17.607
For those considering hard drives as a long-term storage solution, which in my opinion is indeed more viable than CDs/DVDs (due to longevity, increased storage density, and the fact that you can "refresh" the written data manually, like tape backups), see my answer to the following question: How much time until an unused hard drive loses its data?
– Breakthrough – 2013-03-18T18:07:42.843