Invalidate Output.Cache entry on new Comment

Topics: Core, Customizing Orchard
Jul 26, 2014 at 1:08 PM
Before I delve in to implementing a way to do this, is there currently any means for which to invalidate a cached item based on a Comment being published.

For example a Blog Entry that has comments enabled, currently a fresh comment will not appear until the Cache has expired.
Jul 26, 2014 at 6:18 PM
As kind of a workaround OutputCache contains a mechanism that attaches a random query string parameter named __r to the URL: after posting the comment you should be taken to this URL. This means that you should be able to see your comment once you posted it; however if you go back to the blog post (or anybody else visits it) through it's standard URL then the comment won't be immediately visible. I think this is a known limitation but probably there is no corresponding issue yet. Would you mind checking and opening one?

Cache entries are automatically invalidated also when there is a container relationship among items; but apparently comments are not "contained by" their parent item.

However OutputCache also keeps track of which items are displayed on a page and invalidates the entry if any of them changes, but this only does anything when a comment is modified, not when posted.