Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Caching not working (Facebook widget example)

Go to End

2 Posts   830 Views


Community Member, 87 Posts

8 February 2012 at 2:54am

Edited: 08/02/2012 3:21am

Hello all!

I am making an example of the book SilverStripe 2.4 Module Extension, ...
The example is a Facebook widget.
When I show the web page with the plugin, it take a long time to show.
Then, I applied the cache in the template, as the book says, but I do not notice any improvement.
Also, if I run with XDebug, every time the page is displayed, the function plugin (Feeds) is executed.
Apparently, no cache is being done, otherwise the function plugin (Feeds) not be executed.
What can be happening?

I am using WAMPServer in Windows 7 / Firefox /


Jose A.

<% cached 'page', LastEdited, CacheSegment %>

<!doctype html>
<html lang="$ContentLocale">

<meta charset="utf-8"/>
<% base_tag %>
<title><% if MetaTitle %>$MetaTitle<% else %>$Title<% end_if %></title>
<link rel="shortcut icon" href="favicon.ico"/>
<!--[if lt IE 9]>
<script src=""></script>



<div><p><b>Please activate JavaScript.</b><br/>Otherwise you won't be able to use all available functions properly...</p></div>

<% end_cached %>

protected function CacheSegment() {

SS_Cache::set_cache_lifetime('any', 3600, 100);

class FacebookFeedWidget extends Widget {
public function Feeds(){

* URL for fetchning the information, convert the returned JSON into an array.
* It is required to use an access_token which in turn mandates https.
user_error('Missing Facebook access token - please get one and add it to your mysite/_config.php: define("FACEBOOK_ACCESS_TOKEN", "&lt;your token&gt;");', E_USER_WARNING);
$url = '' . $this->Identifier . '/feed?limit=' . ($this->Limit + 5) . '&access_token=' . FACEBOOK_ACCESS_TOKEN;
$context = stream_context_create(array('http' => array('header'=>'Connection: close')));

$facebook = json_decode(file_get_contents($url,false,$context), true);
........ Another code



Community Member, 87 Posts

13 February 2012 at 9:56pm


Does anyone have any ideas about this?

Jose A.