Fresh fish rapidly deteriorates unless some way can be found to preserve it. Drying is a method of food preservation that works by removing water from the food, which inhibits the growth of microorganisms. Open air drying using sun and wind has been practiced since ancient times to preserve food. Water is usually removed by evaporation (air drying, sun drying, smoking or wind drying) but, in the case of freeze-drying, food is first frozen and then the water is removed by sublimation. Bacteria, yeasts and molds need the water in the food to grow, and drying effectively prevents them from surviving in the food.
 Fish are preserved through such traditional methods as drying, smoking and salting. The oldest traditional way of preserving fish was to let the wind and sun dry it. Drying food is the world's oldest known preservation method, and dried fish has a storage life of several years. The method is cheap and effective in suitable climates; the work can be done by the fisherman and family, and the resulting product is easily transported to market.
 Stockfish is unsalted fish, especially cod, dried by cold air and wind on wooden racks on the foreshore. The drying racks are known as fish flakes. Cod is the most common fish used in stockfish production, though other whitefish, such as pollock, haddock, ling and tusk, are also used.
 Over the centuries, several variants of dried fish have evolved. Stockfish, dried as fresh fish and not salted, is often confused with clipfish, where the fish is salted before drying. After 2–3 weeks in salt the fish has saltmatured, and is transformed from wet salted fish to Clipfish through a drying process. The salted fish was earlier dried on rocks (clips) on the foreshore. The production method of Clipfish (or Bacalhau in Portuguese) was developed by the Portuguese who first mined salt near the brackish water of Aveiro, and brought it to Newfoundland where cod was available in massive quantities. (q.v.). Salting was not economically feasible until the 17th century, when cheap salt from southern Europe became available to the maritime nations of northern Europe.
 Stockfish is cured in a process called fermentation where cold adapted bacteria matures the fish, similar to the maturing process of cheese. Clipfish is processed in a chemical curing process called saltmaturing, similar to the maturing processes of other saltmatured products like the Parma ham.
 The water activity, aw, in a fish is defined as the ratio of the water vapour pressure in the flesh of the fish to the vapour pressure of pure water at the same temperature and pressure. It ranges between 0 and 1, and is a parameter that measures how available the water is in the flesh of the fish. Available water is necessary for the microbial and enzymatic reactions involved in spoilage. There are a number of techniques that have been or are used to tie up the available water or remove it by reducing the aw. Traditionally, techniques such as drying, salting and smoking have been used, and have been used for thousands of years. These techniques can be very simple, for example, by using solar drying. In more recent times, freeze-drying, water binding humectants, and fully automated equipment with temperature and humidity control have been added. Often a combination of these techniques is used.
 Salt cod has been produced for at least 500 years, since the time of the European discoveries of the New World. Before refrigeration, there was a need to preserve the codfish; drying and salting are ancient techniques to preserve nutrients and the process makes the codfish tastier.
 The Portuguese tried to use this method of drying and salting on several varieties of fish from their waters, but the ideal fish came from much further north. With the "discovery" of Newfoundland in 1497, long after the Basque whalers arrived in Channel-Port aux Basques[citation needed], they started fishing its cod-rich Grand Banks.  Thus, bacalhau became a staple of the Portuguese cuisine, nicknamed Fiel amigo (faithful friend). From the 18th century, the town of Kristiansund in Norway became an important place of purchasing bacalhau or klippfisk (literally "cliff fish", since the fish was dried on stone cliffs by the sea to begin with.) Since the method was introduced by the Dutchman Jappe Ippes around 1690, the town had produced klippfisk and when the Spanish merchants arrived, it became a big industry. The bacalhau or bacalao dish is sometimes said to originate from Kristiansund, where it was introduced by the Spanish and Portuguese fish buyers and became very popular. Bacalao was common food in northwest Norway to this day, as it was cheap to make. In more recent years, it has become less of an everyday staple and mostly eaten on special occasions.
 This dish was also popular in Portugal and other Roman Catholic countries, because of the many days (Fridays, Lent, and other festivals) on which the Church forbade the eating of meat. Bacalhau dishes were eaten instead.