Fetch a remote URL and cache the result for a certain period of time.

This function originally used file_get_contents(), hence the function name. While it no longer does, it still operates the same as the basic PHP function.

We strongly recommend not using a $timeout value of more than 3 seconds as this function makes blocking requests (stops page generation and waits for the response).

The $extra_args are: * obey_cache_control_header: uses the “cache-control” “max-age” value if greater than $cache_time. * http_api_args: see http://codex.wordpress.org/Function_API/wp_remote_get


Name Type Description
$url string URL to fetch
$timeout int Optional. The timeout limit in seconds; valid values are 1-10. Defaults to 3.
$cache_time int Optional. The minimum cache time in seconds. Valid values are >= 60. Defaults to 900.
$extra_args array Optional. Advanced arguments: "obey_cache_control_header" and "http_api_args".

Return Value

string: The remote file's contents (cached)

Ready to get started?

Drop us a note.

No matter where you are in the planning process, we’re happy to help, and we’re actual humans here on the other side of the form. 👋 We’re here to discuss your challenges and plans, evaluate your existing resources or a potential partner, or even make some initial recommendations. And, of course, we’re here to help any time you’re in the market for some robust WordPress awesomeness.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.