Edge computing deploys computing and storage resources on the edge of the network close to users, so that users can offload high-latency and energy-intensive applications to the edge of the network for execution to reduce application latency and local energy consumption. Existing offloading research usually assumes that the offloaded tasks are independent of each other, and the edge server caches all the services required for task execution. However, in real scenarios, there are often dependencies between tasks, and edge servers can only cache limited services due to their limited storage resources. To this end, this paper proposes a dependency task offloading method that balances latency and energy consumption (i.e., cost) under the constraints of limited computing resources and service caches on edge servers. First, the constraints in the research problem are relaxed to transform it into a convex optimization problem. A convex optimization tool is used to find the optimal solution, which is used to calculate the priority of offloading tasks. Then, the tasks are offloaded to the edge server with the least cost according to the priority. If multiple dependent tasks are offloaded to different edge servers, an improved particle swarm optimization is used to solve the optimal transmission power of edge servers to minimize the total cost. Finally, sufficient experiments are performed based on real datasets to verify the effectiveness of the proposed method. The experimental results show that the proposed method can reduce the total cost by approximately 8% to 23% compared with other methods.