Fats can be kept fresh and unrancid longest by keeping at very cool temperatures and in the dark, and away from exposure to oxygen & moisture of the atmosphere. Ideally this would mean in refrigeration without light or in a light-blocking container, and either vacuum-sealed or else with airspace filled with nitrogen or other nontoxic gas without oxygen.