I usually take à shortcut and cache the actual expensive data instead.
Use ISynchronizedObjectInstanceCache if choosing this path
Expensive data is already cached to the hills to where it can be, I'm just testing out performance improvements on an already near ready to go live website.
Not a direct aswer to your question, but I assume you are trying to outputcache the individual block instances.
I have had good results with using the OutputCache on the BlockController with VaryByParam="currentBlock". Then on the BlockData class override the ToString() function to return a block instance specific string like:
public override string ToString() { IContent content = this as IContent; IChangeTrackable changetrackable = this as IChangeTrackable; //IVersionable version = this as IVersionable; if (content != null && changetrackable != null) return String.Format("{0}-{1}-{2}", content.ContentGuid, changetrackable.Saved.Ticks, EPiServer.Editor.PageEditing.PageIsInEditMode); return base.ToString(); }
One more note, I also use VaryByCustom="language" on the OutputCache attribute to differentiate between the 6 languages my site has. The value for the 'language' I set in a GetVaryByCustomString override in Global.asax.
Thanks, that's what I've done before myslef for language. Just getting donut hole caching in EpiServer for the block was annoying. Thanks for the help
Does anyone know how to get the ContentReference of the current block when using OutputCache on a block Controller and VaryByCustom?
Within using this and writing code in the GetVaryByCustomString method HttpContext.Current.Request.RequestContext.GetContentLink(); only returns the page ContentLink.
Thanks,
Scott