Shares gain for second day but caution persists