The shelf life of oil varies depending on how the oil is handled and what kind of oil it is. As a general rule, cooking oils can last six months after they are opened, but this varies considerably. Regardless as to the shelf life an oil is supposed to have, it is a very good idea to taste oils before use if they have not been used in a while to determine whether or nor they have gone rancid. Rancid oil will ruin a carefully-assembled dish, and that would be a great pity.
Leaching of flavors and chemicals can also affect the shelf life of an oil. If the oil is not stored in an inert container, flavors from the kitchen may seep in, and some of those flavors might be surprising and very undesirable.
Sealed oil can typically be held in a cool, dark, dry place for up to one year. Once oil is opened, it should continue to be stored in a cool, dark, dry place, and it should be kept as tightly sealed as possible, because exposure to air is what causes oil to go rancid. To prolong the shelf life of oil, you can refrigerate it. All oils can be stored in the fridge, and although they will thicken up a bit, they will go rancid a lot less quickly, and many people think that the thickness is worth it to prolong the shelf life of oil.
Vegetable oils such as peanut, palm, rice bran, corn, and coconut oil can keep for a year sealed, and six months after opening. They are usually very shelf-stable in a cool dry place, although they can certainly be refrigerated. For best results, keep the oil in glass, if possible, because glass is inert, so it is less likely to leach strange flavors, including the flavors of foods cooked nearby, into the oil. When you purchase new oil, make a note of the date stamped on the package, and consider writing the date you opened the oil on the container so that you will be able to keep track of how long it has been sitting around.
More delicate oils like grapeseed, apricot kernel, avocado, sesame, and walnut oil can keep for four to six months after opening, and they really should be refrigerated. Flaxseed oil keeps around a month, losing most of its benefits after just three weeks, while olive oil can keep for a year in the fridge, and six to nine months at room temperature. Oil stored in the fridge can be kept in wide-mouthed containers to facilitate pouring as it thickens up in the refrigerator.
The shelf life of oil is also improved when it is stored in a clean container. If you buy oil in bulk at the store or pull oil from large drums into smaller bottles for household use, you should make sure that your containers are spotlessly clean. If old oil is left behind, it can make the new oil go rancid, sometimes very quickly, especially if it has been sitting around for some time.