Optimal path following for robots considers the problem of moving along a predetermined Cartesian geometric end effector path (which is transformed into a predetermined geometric joint path), while some objective is minimized: e.g. motion time or energy loss. In practice it is often not required to follow a path exactly but only within a certain tolerance. By deviating from the path, within the allowable tolerance, one could gain in optimality. In this paper, we define the allowable deviation from the path as a tube around the given geometric path. We then search for the optimal motion inside the tube. This transforms the path following problem to a tube following problem. In contrast to the (time or energy) optimal path following problem, the tube following problem is not convex. However, we propose a problem formulation that can still be solved efficiently, as will be illustrated by some numerical examples.