Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Karine bosch caching-spsbe14


Published on

You can build very attractive sites but if your pages don't render within the second, you will be out of visitors in no time. Highly performing SharePoint sites can be a true challenge.
In this session I will explain how the different caching mechanism can highly improve the performance of your SharePoint Publishing site.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Karine bosch caching-spsbe14

  1. 1. #SPSBEBoosting Performance on Publishing sites #SPSBE14 Karine Bosch SharePoint MVP
  2. 2. A big thanks to our sponsorsPlatinum SponsorsGold Premium Sponsors Venue SponsorGold Sponsors
  3. 3. About me• SharePoint MVP since 2008• Technical assistent of Patrick Tisseghem till September 2008• Developer of the U2U CAML Builder• Technical Lead SharePoint Competence Center @ ING• Blog:• Twitter: kbosie
  4. 4. Agenda• Introduction• Caching data• Techniques to reduce the page load• Tools to measure performance
  5. 5. Introduction• Data is stored in SQL Server database• User requests require data No Caching 2. SQL Get Data 1. HTTP GET 3. Data Returned 4. HTTP Response• No caching limits scalability• SharePoint caches run on the WFE(s)• Caches maintain copies of data locally on WFE• User requests are served from cache on WFE
  6. 6. Types of Caching• Caching data • BLOB Cache => caches files stored in the content database • IIS Cache => caches files stored in the _layouts folder • Output Cache => caches .aspx pages • Object Cache => caches data objects• Require addintional system resources
  7. 7. BLOB Cache• BLOB = Binary Large Object• BLOB cache is configured on Web Application level in web.config• BLOB cache stores files from content database on a local directory of each WFE • Images, CSS files, JavaScript files• Second request serves file from disk• Tradeoff: • Extra roundtrips to SQL Server to fetch file• Cache Invalidation
  8. 8. BLOB Cache• BLOB Cache is highly optimized to serve anonymous requests • Images and SiteCollectionImages library have AllowEveryoneViewItems property set to True. • No SQL Server roundtrip to check user ACLs• Adds cache control headers to HTTP Responses to save file in user’s browser cache
  9. 9. BLOB Cache• BLOB Caching is useful when • Resources are frequently accessed • Rich media is used (videos, etc)• BLOB Caching is less useful when • Resources are not frequently accessed • Files are modified frequently
  10. 10. Configuring BLOB Cache• BLOB Cache is configured in web.config of WFE • Local directory on WFE • Files with specific extensions • List of extensions can be configured • Size limit <BlobCache location="C:blobCache" path=".(gif|jpg|png|css|js)$" maxSize="10" max-age="86400" enabled="true"/>
  11. 11. Demo BLOB Cache
  12. 12. IIS Cache• Files stored in _layouts/images folder of WFE• Files are cached on local browser cache• Default invalidation period: 365 days
  13. 13. Demo IIS Caching
  14. 14. Output Cache• SharePoint Server uses ASP.NET output cache • In-memory cache that stores rendered ASPX pages per ASP.NET application • Reduces CPU load and SQL Server roundtrips• In SharePoint Server only Publishing pages can be cached • Publishing Feature fetches page layout and then content of the page• Configured per site collection• Output Cache is highly optimized for anonymous access• Memory requirements: • (2 x page size) + 32 KB of memory per rendered copy of a page
  15. 15. Output Cache Profiles• Configuration of Cache profiles • Specify the different variants of a page that can be stored in cache • Vary By• Default cache profiles • Organaized by • user access rights • Browser type
  16. 16. Configuring Output Cache• Following features must be enabled: • Publishing Infrastructure site collection feature • Publishing site feature• Site collection settings > Site collection output cache • Enable output cache check box
  17. 17. Configuring Cache Profiles• Cache Profiles specify the different variants of a page that can be stored in cache• Site collection settings > Site collection cache profiles• Fields that can be configured • Enabled • Duration • Check for Changes • Vary By Parameter • Perform ACL check • …
  18. 18. Demo Output Cache
  19. 19. Object Cache• Stores data objects in-memory on WFEs• Publishing features must be activated• Some SharePoint artifacts use object cache mechanism by design: • Cross-list Query Cache • Content By Query Web Part • PortalSiteMapProvider API • Search Query Box • Metadata navigation• HttpRuntime.Cache
  20. 20. Object Cache• Data is cached based on user rights • PortalSuperUserAccount • PortalSuperReaderAccount• Cache invalidation• Size: allocate 500KB RAM per site collection
  21. 21. Configuring Object Cache• Set up Portal Super Accounts $wa = Get-SPWebApplication -Identity "<WebApplication>" $wa.Properties["portalsuperuseraccount"] = "<SuperUser>" $wa.Properties["portalsuperreaderaccount"] = "<SuperReader>" $wa.Update()• Site collection settings > Site collection object cache• Tuning options • Max size • Flushing • Cache Invalidation
  22. 22. HttpRuntime.Cache Code Sample• ASP.NET cache class string cacheKey = "BeersOfTheWeek"; List<Beer> beerList = null;• Cache key // check the cache object o = HttpRuntime.Cache.Get(cacheKey);• Lock before retrieving data from database if (o == null) { object lockHandle = new object();• Insert object(s) in cache for lock (lockHandle) { a certain period of time // check again if cache is not filled again o = HttpRuntime.Cache.Get(cacheKey); if (o == null) { beerList = RetrieveWithQuery(); if (beerList != null) { // add the list to the cache HttpRuntime.Cache.Insert(cacheKey, beerList, null, DateTime.Now.AddMinutes(15.0), TimeSpan.Zero); } } else beerList = (List<Beer>)o; } } else beerList = (List<Beer>)o;
  23. 23. Demo Object Caching
  24. 24. Tools• Tools to measure performance and page load • Firebug • Yslow • Developer Dashboard • SPMonitoredScope
  25. 25. Developer Dashboard• Disabled by default• Can be enabled via • Object Model • Stsadm • PowerShell• Display levels • On • Off • On Demand
  26. 26. SPMonitoredScope• Included for web parts• Not included for custom controls using (SPMonitoredScope breweryBannerScope = new SPMonitoredScope(“Brewery Banner control”) { // your code goes here }
  27. 27. Demo Developer Dashboard and SPMonitoredScope
  28. 28. Reduce the Page Load• Suppress JavaScript files and CSS files that are not used in anonymous mode• Minimize JavaScript files• Sprites • Images • CSS
  29. 29. Conclusion• Improve performance using caching mechanisms: • BLOB cache => files in document libraries • IIS cache => files in _layouts folder • Output cache => publishing pages • Object cache => data objects• Caching takes place on: • Web front ends • Client browser
  30. 30. We need your feedback! Scan this QR code or visit Our sponsors: