The reason your horse gets better the more you ride him is because there is more circulation in there legs when you ride. When my horse foundered I had to ride her with hard work for an hour because it helps with circulation, it's important for foundered horses to have lots of circulation in the feet because it will help the bone and laminae grow back properly
It sounds like he might just be stalked up. It can be the result of standing in a stall for prolonged periods of time, or standing still after working. Most often it is completely harmless and the swelling will go away with work, and if they are off, it is only a slight lameness which gets better with movement.