In this paper, we tackle the critical challenges of content edge caching, such as limited storage capacity, content popularity prediction, dynamic user demand, and user privacy, issues that most existing studies only address partially. We present an innovative Genetic Algorithm-based On-demand Collaborative Edge Caching mechanism (GAOCEC), which introduces a multi-tiered caching architecture integrating cloud, fog, and edge computing. To enhance caching efficiency and minimize system cost, a novel on-demand caching quota mechanism is proposed that dynamically allocates cache resources to edge servers. To strengthen user privacy protection during content popularity prediction, a CNN-BiLSTM-based Federated Learning algorithm (CBFL) is presented that ensures high prediction accuracy without the need to upload local data to the cloud. We also refine the genetic algorithm for content placement by fine-tuning various parameter sets to identify the optimal balance between latency reduction and caching cost. Our experimental results validate the effectiveness of our approach, demonstrating increased cache hit rates, decreased content response times, and an overall improvement in system efficiency. This work provides a comprehensive, adaptive, and privacy-preserving solution for the edge–fog–cloud environment.