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.

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

How to use static cacheing with comments enabled

Go to End

2 Posts   1071 Views


Community Member, 102 Posts

28 March 2012 at 12:49am

If almost any page can have comments, then static cacheing can't be used useless there's a way to cache the comments too.

How can a page be automatically recached when a new comment is submitted?

In the example code here, the subPagesToCache function checks for comments to cache the rss feed...

		// cache the RSS feed if comments are enabled
		if ($this->ProvideComments) {
			$urls[] = Director::absoluteBaseURL() . "pagecomment/rss/" . $this->ID;
		} it looks like the author has considered the issue of comments, but there's no indication of how to show them.

Any ideas? What about dealing with comment form submissions, spam protection mesages etc. Surely someone has already worked all this out? What about using static cacheing with the Blog module e.g. paged results, widgets etc. Has that been tried successfully, or is it not worth it & better to stick with partial cacheing?

Thanks, Jules


Forum Moderator, 5523 Posts

28 March 2012 at 8:31pm

You can statically cache pagination (by augmenting the subPagesToCache() function). You could get comments working by adding a cache rebuild trigger on an extension to Comments, onAfterWrite but for the majority of sites partial caching might be suitable effort.