Books aren't bad, experimentation aint bad. Watching shit loads of comedy until the lessons are hammered into your quivering brain matter is best.
Watch and practise, watch and practise.
Then bore anyone you can get your hands on.
Right now Stewart Lee is offering a master class in gag writing masquerading as a comedy show on 2. Watch how he takes seemingly weak assed gags, undersells them and by spinning them into giant meta gags destroys the audience.
And when you write gags don't settle for a simple pun or word play. Structure it, expand it make it sing.