CDNs are just reverse proxies. Cloudflare was built around nginx (though they have now developed their own reverse proxy) and so do most CDNs. Fastly uses Varnish. A few use Apache Traffic Server. A correctly configured nginx can easily manage caches by various rules like minimum hits, maximum age etc.