»WordPress»WordPress gets the remote file content and displays it
Using curl extension, theme developers can push information to theme/plug-in users, which is definitely a practical technology
preface
During the theme development yesterday, I had an idea that we should communicate with the theme users, or push some information to the users, such as the use skills of the theme. So Baidu found that the website has a similar solution. I made a new one and successfully implanted the current theme of the site. Let's share it by the way.
introduce
The method to obtain remote file content is mainly to usefopen/file_get_contents/curlThree methods, butfopen/file_get_contentsDNS query will be performed again for each request, and DNS information will not be cached.howeverCURLThe DNS information is automatically cached.The request for a web page or image under the same domain name requires only one DNS query.This greatly reduces the number of DNS queries.
So the performance of CURL is much better than that of fopen/file_get_contents
It's OK to create a txt text locally on your server. I build it in Git, and then the theme automatically gets the text. After the update here, the client will immediately change under the refresh.