I currently run a website that pulls in a rss feed and you can go to the links the problem i am having is when i click on a rss link it takes me to a webpage but that webpage will load really slow.
I am looking to cache that webpage so it loads really quickly, what is the best way to do this i can create a cache folder in my project and then cache each file to that folder and then serve from their example below.
<?php
foreach ($source_xml->channel->item as $rss) {
$title = trim($rss->title);
$link = $rss->link;
$html = $title . '.html';
$homepage = file_get_contents($link);
file_put_contents('cache/' . $html, $homepage);
}
?>
This takes quite long with alot of feeds and i am not sure if this is the most productive way i have also tried creating a database and have a extra field called cache that is a text field, i then store the output from file_get_contents in there example below.
<?php
foreach ($source_xml->channel->item as $rss) {
$title = trim($rss->title);
$link = $rss->link;
$cache = file_get_contents($link);
$data = array(
'title' => $title,
'link' => $link,
'cache' => $cache
);
echo $this->cron_model->addResults($data);
}
?>
This works but i get this issue when looking at the mysql
Because of its length,
this column might not be editable
I am not familiar with caching and have never really needed to deal with it since now can someone give me some best practise advice i know i can hack something together but would prefer to know the right way before going forward.
Thanks