Dry foods, while designed to be stable for storage, can actually degrade quickly once the bag is opened and oxidation begins.  This is especially true of foods containing fish and fish oil, which go rancid more quickly than other fats.
Trust your nose (and your dog’s nose)!
Rancid fats may make your dog sick, or they may just refuse to eat. If your dog refuses their food or throws it up give it the sniff test yourself. If this type of thing occurs when that large bag of kibble is almost gone it’s a pretty sure bet that the food has gone rancid and you need to up your game on purchasing and storing your pet’s food.
Aim to feed your pet’s dry food within two weeks of opening the bag.
Yes. Two weeks.
If you cannot reliably do that and cannot buy a smaller bag, freeze the food in one week packages as soon as you open it (use proper freezer bags to ensure no moisture gets in).
Always store dry food in a cool, dry place. That means for most folks the garage is off-limits.
Always keep the original packaging. This is important in case there is a recall or your pet gets sick and you need to return the food and report the illness to the company. The bag has the information the company needs to track the exact batch of food.
The original bag also provides a safer surface than your typical plastic bin, so if you’re used to dumping out your pets food into a plastic bin please keep it in the bag and put the whole bag in (and if you can’t fit it that might be a another clue that you need to freeze some of it or simply buy a smaller bag.
Always check the production or “best by” date when purchasing your food. Dry foods are generally considered shelf stable in a sealed bag for one year, so if there is only a “best by” date be sure it’s not coming up soon. If you do find a bag that’s close to or past the “best by” date inform the store. Even stores that are diligent about rotating their stock can lose track of a bag here or there and will thank you for bringing it to their attention. You may find that you need to special order your favorite food if it’s not a big seller, but that’s much better than buying a bag that’s been sitting around a store for months.
Dry food is convenience food, but it’s not indestructible. For more details about this issue read this short article by Steve Brown.