Buy a ferry ticket in advance. Of course this is not valid for short ferry crossing where you simply stay in line and just cross something. We are talking about ferry few hours long and few hundred euro; or whatever the currency.
Just like with the airline tickets first figure out who goes from where and when. Then simply use direct web sites of the ferry companies to reserve a crossing. Rarely ferry booking sites will give you a better price than direct booking.
Do consider different ports and specially different days of the week. Because this is a major factor. Saturdays tends to be more expensive. Consider night crossings and odd hours, you will have to wait in the port anyway.
Prices do not change daily or weekly. They do change or offer a discount, but generally this is done on a monthly basis. The prices tend to rise, so be an early bird. Book in January for July.
On site, just before the embarking the prices will not be decrease, because what will you do in the port if you don’t like the price? Turn around?
Rooms, if not sold out, will be offered at a discount, so you can speculate or simply sleep on deck, you are on a ferry anyway.
Food and beverage you can bring as much as you can on most ferries so take a good supermarket supply with you. That is all, good bargain ferry hunting.