Jump to content

How to cache the external footer from a live site i.e. to be placed in IP.Board


Recommended Posts

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.

 

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

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

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

 

:)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.