No matter how clean you keep your kitchen, pests cans still cause problems in your pantry. They enter your home in a variety of ways and seek out improperly stored foods to lay eggs in. The eggs hatch into larva that look like worms, and they can spoil your food as they grow into full-fledged insects. The key to preventing worms in your food is to be proactive and make sure your flours and grains are stored properly as soon as you get home from the store.
If you are going to be using a package of flour or grains within a short amount of time, it's unlikely you will have problems with pantry pests as long as the packaging is intact, without tears or holes. However, cardboard, paper and plastic will not keep insects out of your food, so transfer your food to a heavy-duty container if you plan to store it for longer than a few weeks. Keep your shelves dry and free of crumbs, because moisture and open food attracts insects. Use older packages of food before newer ones and don't store new packages next to older ones; if the older packages are infested with insects they can move to the new packaging.
The best way to prevent insects from invading your flours and grains is to store them in glass or metal containers. Very heavy-duty plastic will also work. Transfer your food to containers with tight-fitting lids, such as a screw-top lid or one with a substantial seal around it. If you're sure the original packaging is free of insect infestation you can put it directly into a container. Look for webbing or holes on the package. It might be easier to empty your flour and grains into containers and provide a scoop for usage.
Flours and grains store well in a refrigerator. This is a good option if you have continual problems with insects despite your best efforts. Store flour in a container with a good lid and tight seal to prevent moisture loss, which can affect the quality of the flour. White flour will store for up to a year in the refrigerator, while whole-wheat flour stays good for six to eight months, according to the Virginia Cooperative Extension. Corn meal can be stored in the refrigerator for up to 18 months. White and brown rice also store well in the refrigerator.
Whole-wheat flour and brown rice actually benefit from being stored in the freezer because it slows the oils in them from going rancid, as they tend to do when stored for long periods at room temperature. White flour, whole-wheat flour and corn meal will keep in the freezer for up to two years. Store rice for up to a year in the freezer. Put your flours and grains in air-tight containers or heavy-duty freezer bags to prevent moisture problems.