There are different shared protection strategies including shared link, segment, and end-to-end path protection. Here we propose a generic optimization framework, referred to as GSP, the Generalised Shared Protection, that yields a shared protection that uses resources optimally along with the primary path for any single demand. The optimization is based on ILP formulation. The optimization implicitly decides whether link, segment or end-to-end path protection is the best solution for a certain demand under given traffic and network conditions. We prove analytically that GSP cannot be outperformed by any of the classical shared protection methods. By intensive simulations we compare the performance of 5 shared protection methods to GSP in case of dynamic traffic. We show that SPP (Shared Path Protection) nearly always provides the same result as GSP, however, GSP is more resilient against double link failures. Furthermore, we show that GSP is as resilient to double link failures as SLP (Shared Link Protection) while it requires significantly less resources and has, therefore, significantly lower cost.