Oxford gives two relevant meanings for "trick":
(3) a skillful action that someone or something performs as a way of entertaining people.
He amused the kids with conjuring tricks.
(4) [usually singular] a way of doing something that works well; a good method. The trick is to pick the animal up by the back of its neck.
In my experience, the trick to with an infinitive will usually be closer to meaning (3), while with a gerund (or a noun) it'll be closer to meaning (4).
A trick to open beer bottles is to wedge your teeth under the cap and gently pull. (it's an amusing, clever, non-obvious way of doing so, like a magic trick, but not necessarily the best one)
A trick to opening beer bottles is to do it slowly, so that the beer does not spill over. (it's good advice, the right method to deal with something tricky that would otherwise be impossible or difficult)
So in your examples, the trick to getting a chair to fold up will probably be something possibly not very obvious, but ultimately fairly mundane once you know about it (eg. "undo this latch first"), however it would be hard to fold the chair up without knowing that. Meanwhile, a trick to speed up your beauty routine would be something clever or non-obvious, such as using a household product in a nonstandard way. You could speed up your beauty routine in different, more mundane ways.