Location is valuable information for services implemented in wireless networks. Location systems often use the infrastructure of cellular networks that have already been deployed. Accordingly, location systems spend resources of the network they use. This paper proposes a middleware to reduce the consumption of network resources and optimize the location traffic that is being carried. This middleware, called MILCO (Middleware for Location Cost Optimization), selects the optimum location technique depending on the request, i.e. the location technique that satisfies the quality of service (QoS) required and minimizes the resource operating expense. In addition, MILCO takes advantage of ongoing and carried location processes to reduce the overall expenditure of resources. Our results show that MILCO can reduce location-process failures and improve latency figures for location provisioning and resource use in cellular networks such as UMTS.