What is the shelf life of gas and diesel? That depends. It depends on the temperature at which the fuel is stored (higher temperatures tend to reduce shelf life). It depends on whether or not the fuel is susceptible to microbial growth (bacteria say mmm mmm biodiesel, not so much for petrochemicals though it does support some algae). It depends on whether or not any natural preservatives or additives are present in the fuel. What is the life expectancy of common fuels? Well... according to Wikipedia (yes, I know, maybe not the most credible source) gasoline is good for about 60 days. With additives and conscientious storage, you can extend the shelf life out to 1-2 years. (Did you watch the movie "Doomsday" in which the main character uncovers a sexy Bentley that has been sitting in a crate for at least 27 years, with its tires miraculously intact? She finds a barrel of gas, fills up the car and drives away. Riiiight.) The shelf life for petroleum diesel that contains additives is about the same.
Biodiesel usability depends on storage conditions, the source oil, and whether or not it contains additives. If you use an oil that contains natural preservatives (e.g., rapeseed oil contains tocopherol, a natural antioxidant), your oil and the resulting biodiesel will be stable somewhat longer than if you used a more perishable vegetable oil (e.g., soybean oil). Some online sources report biodiesel is stable for up for 6 months, but I presume that is a reference to fuel which contains commercial additives, such as Baynox®. Biodiesel that you would make at home probably won't contain a commercial additive, though you can extend its life somewhat by adding vitamin E. Otherwise, you may obtain a product with an optimal shelf life as low as 10 days. As I have mentioned, storage conditions are critical. Shelf life is affected by exposure to light, water, heat, and air. Temperatures as low as 110°F may compromise the stability of the fuel.
What does this mean for you? Unless you drive a lot, you might want to tailor how much fuel you put in your vehicle to how quickly you will burn it. If you are the type of person who likes to keep a full tank of fuel in your automobile, you might consider refueling at 1/4th or 1/8th of a tank instead. If you are making biodiesel, or any fuel, it might make sense to produce the fuel in manageable batches that you will use in the foreseeable future, rather than seeking to stockpile the fuel for future use.