Re: Options for WebPart Caching

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hello Michael,

You're probably best of using web part caching. You can use it via the PartCacheWrite and PartCacheRead methods of the WebPart class. One of the arguments you can input is Storage.Personal, which caches per user, see example:

PartCacheWrite(Storage.Personal, "mykey", "myvalue", TimeSpan.FromMinutes(5));

You can write cache in either the database or the ASP.NET cache object using this method. Be aware of the fact that the total amount of allowed cache of Shared and Personal cache in database mode is limited to 2 MB.

Kind regards,
Nikander & Margriet Bruggeman

I have a question about the best strategy for caching a web part.  The
web part in question walks the sites structure and obviously would
encounter some performance issues with this.  This iteration populates
a DataTable that would not change frequently but varies per user.    I
don't think that storing it in the session would be the best option
and am leaning towards putting it in the cache but am unsure as to
whether cache the whole web part or just the DataTable.  Any advise in
this and how to cache per user would be appreciated.

Thanks,

Michael Fischer




.