PHP:缓存Facebook Graph API结果

I use Facebook Graph API to fetch my Facebook Fans pages ( 7 Facebook pages in total ) with the following codes :

<?php
header('Content-Type: text/plain; charset=utf-8');
require_once('facebook.php');
$facebook = new Facebook(array(
    'appId'  => 'MY_APP_ID',
    'secret' => 'MY_APP_SECRET',
));

$page_feed_1 = $facebook->api('MY_FB_PAGE_ID_1/feed');
$page_feed_2 = $facebook->api('MY_FB_PAGE_ID_2/feed');
// ... etc
?>

I plan to cache the JSON result to file and the output page ( which displays the contents of the Facebook pages ) loads from the cache files. But what should my loading sequence if I can't use cron job ( yes, my web server is Linux-based ) ?

My current plan is :

  1. When the output page loads, check for cache file, if yes, load the cache file
  2. Use a deferred JavaScript to create an AJAX call to a PHP script to fetch updated contents from Facebook and save to cache file

The problem I can now think of is, when many users visit the output page, the cache will refresh many times. How can I check the last update time of my Facebook page? If the content is the same, the cache won't refresh.

Note: My question is not about parsing JSON / Array in PHP.

My final solution is to call the Facebook API with a PHP script, which is executed periodically by cronjob.

The tricky part is to obtain a never-expiring static token from Facebook using Facebook Token Exchange, which saves time from requesting a new token, and skip the need of logging in with a user account.