sunil_23413 Posted March 12, 2009 Share Posted March 12, 2009 Well I am going to fetch footer (any content) from an external site. Want to cache it for 2o minutes and place it at a position in my ipboard site. As I am newbie to IP.Board 2.3.I don’t know how caching is done in IP.Board 2.3. So I am not able to cache the external footer from a live site. Well as all the content of ipboard has inbuilt cacheing. But the external footer fetched from other site is taking a lot time to load as I am not able to cache it. Or simply anyone as a suggestion on how to cache any content fetched from any other live site. I want to cache all the content including images. Quote Link to comment https://forums.phpfreaks.com/topic/149084-how-to-cache-the-external-footer-from-a-live-site-ie-to-be-placed-in-ipboard/ Share on other sites More sharing options...
MadTechie Posted March 13, 2009 Share Posted March 13, 2009 try something like this <?php $cachetime = 20*60*60; $cacheFile = "path/to/writeable_dir/ipcache.cache"; $sourceFile="http://ipboard.com/index.php"; if(file_exists($cacheFile) && (filectime($cacheFile) < time()+$cachetime)) { readfile($sourceFile); exit; } $data = file_get_contents($sourceFile); file_put_cotents($cacheFile,$data); echo $data; ?> basically gets the page, saves to file, next run checks if the file was updated in the last 20 minutes if not re-gets the data, if so read from the file Quote Link to comment https://forums.phpfreaks.com/topic/149084-how-to-cache-the-external-footer-from-a-live-site-ie-to-be-placed-in-ipboard/#findComment-783448 Share on other sites More sharing options...
sunil_23413 Posted March 13, 2009 Author Share Posted March 13, 2009 thanks a lot, i got you point and i am able to cache it as you told in the post. but there is a large sized image file and flash file in the footer. So even after cacheing the footer it is taking a lot of time to load as the image and flash file are fetched from the live url. is there any way to save or cache the image and flash files so that image and flash files are fetched from the cache and not from live url Quote Link to comment https://forums.phpfreaks.com/topic/149084-how-to-cache-the-external-footer-from-a-live-site-ie-to-be-placed-in-ipboard/#findComment-783642 Share on other sites More sharing options...
MadTechie Posted March 13, 2009 Share Posted March 13, 2009 I guess the easy option is to save a copy of the file(s) to your server and then add a simple replace $data = file_get_contents($sourceFile); $data = str_replace("otherdomain.com/largeflash.swf","mycache/largeflash.swf",$data);//add Quote Link to comment https://forums.phpfreaks.com/topic/149084-how-to-cache-the-external-footer-from-a-live-site-ie-to-be-placed-in-ipboard/#findComment-783762 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.