The invention discloses an online collaborative caching method based on optimized energy efficiency, which belongs to the technical field of communication and comprises the following steps of firstly,establishing a double-layer heterogeneous ultra-dense network scene comprising a content server CP, a macro base station MBS, a small base station SBS and user UE; aiming at the new content l to becached, enabling an MBS to calculate a preference factor and a social factor of a certain user UE for the content; further obtaining a preference factor and a social factor of each piece of UE on thecontent, calculating a decision function value by combining the current heat factor of the content l, adding the content l into the cache file set when the decision function value l is greater than orequal to a judgment threshold I0, and meanwhile, calculating each SBS capable of caching the content by MBS; judging whether each SBS needing to cache the content l and the MBS have enough cache space or not, and if so, directly caching the content l; otherwise, deleting from the most recently requested file until the cache space is sufficient to store the content l. According to the invention, the real-time distribution of the cache content can be realized, the energy consumption is saved, and the network cost is saved.