A lesson I did not learn: I dedicated each lunch hour every day for a couple of months ringing up companies and agencies. I moved jobs three times and doubled my salary in that year - which seemed good.
Then I attended a seminar - the question was asked who used agencies and who used their "network" for new jobs / freelance work.
I was the only hand up to go used agencies and the traditional job hunt.
So it's the old saw - keep a profile up - blog, project, podcast whatever, so you can use that as an excuse to stay in touch with ex-colleagues so that they might think of you when they are hiring in 3 years.
As I said not a lesson I have learned but people who earn more than me recommend it