No single recipe
The latest white paper from Expedia suggests 57 days before departure as the day when average prices are the cheapest. Earlier report from CheapAir focused on US domestic flights shows that 47 days to departure is the optimal moment to buy. There are more similar studies all giving different answers.
There is no common answer about the exact number of days, but the general trend is that booking too early is not always the best strategy. It depends on airline and several other factors which we explain below.
Traditional vs. low-cost airlines
For traditional airlines such as United Airlines, British Airways or Lufthansa it is better to book early, especially for international flights. There are always chances to find a special promotion or sale later, but it is rather an exception than the rule.
For low-cost airlines, such as Ryanair, EasyJet or Southwest, the strategy is different. They use more aggressive yield (price) management algorithms to raise or lower prices depending on the current supply and demand. So it is pretty common to see somewhat higher prices long time to departure and then prices dropping if there is not enough demand. To illustrate this behavior we have published the following articles about Ryanair and EasyJet.
Day of week to book flights
Different studies suggest that the day of week and even time of day of booking matters for finding the cheapest airfares. The studies generally agreed that booking mid-week (Tuesday-Thursday) enables better chances of finding the cheapest airfares. However researchers disagree about which days is the best for buying. Some seem to highlight Tuesday, while others suggest Thursday. This also depends on concrete airlines. Our study of Ryanair prices confirms the mid-week hypothesis.
Day of departure
If your travel dates are flexible, it is recommended to avoid weekend departures, which are generally more expensive than flying on weekdays.
During holidays, school vacations or special events flight prices always go up. So if you have to fly on those dates and are not flexible, it is better to book early. This is true even when flying with low-cost airlines, which alter prices based on current demand. For holiday flights departing 2-3 days earlier/later than rush hour days, could save you even up to 200% of the ticket price.
Tools which can help
It is not trivial to take all these factor into account and constantly analyze price changes during long periods of time. There are tools online which can help finding the best moment to book tickets.
Available at Kayak, Skyscanner and many other websites
Flexible flight search
Using flight search engine which can search more multiple airlines, flexible dates and alternative routes.
Some websites predict whether it is a good moment to buy a ticket or it is better to wait. Kayak has a general prediction model available for some flights. To find cheap flights for low-cost airlines such as Ryanair, EasyJet and Vueling, you can try Airhint price predictor which has the prediction model tailored for those airlines.