Curl DNS Cache Settings

Source: Internet
Author: User

When Curlopt_dns_use_global_cache is enabled, a global DNS cache is enabled, which is thread-safe and enabled by default.
Curlopt_dns_cache_timeout sets the time to save DNS information in memory by default of 120 seconds.

1) fopen/file_get_contents each request for data in the remote URL will be re-made to the DNS query, and the DNS information is not cached. However, Curl automatically caches the DNS information. Requests for Web pages or images under the same domain name require only one DNS query. This greatly reduces the number of DNS queries. So curl has a much better performance than fopen/file_get_contents.
2) fopen/file_get_contents is using Http_fopen_wrapper when requesting HTTP, and will not keeplive. and curl can. This makes curl more efficient when multiple links are requested more than once. (The header should be set)

So, such as internal needs constantly request intranet DNS server, try to add, with curl

or with DNSMASQ.

Curl DNS Cache Settings

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.