I have a website, that uses WP Super Cache plugin. I need to recycle cache once a day and then I need to call 5 posts (URL adresses) so WP Super Cache put these posts into cache again (caching is quite time consuming so I’d like to have it precached before users come so they dont have to wait).
On my hosting I can use a CRON but only for 1 call/hour. And I need to call 5 different URL’s at once.
Is it possible to do that? Maybe create one HTML page with these 5 posts in iframe? Will something like that work?
Edit: Shell is not available, so I have to use PHP scripting.
The easiest way to do it in PHP is to use
file_get_contents()
(fopen()
also works), if the HTTP stream wrapper is enabled on your server:If
file_get_contents()
fails to open the URLs on your server (some ISP restrict this behaviour) you can try to usecurl
:Then use the function
curl_get_contents()
listed above instead offile_get_contents()
.An example using PHP without building a
cURL
request.Using PHP’s shell exec, you can have an extremely light function like so :
Now of course this is not the most concise answer and not always a good solution also, if you actually want anything from the response you will have to work with it a different way to
cURL
but its a low impact option.Thanks to Arkascha tip I created a PHP page that I call from CRON. This page contains simple function using cURL: