Karine bosch caching-spsbe14
-
Upload
biwug -
Category
Technology
-
view
633 -
download
2
description
Transcript of Karine bosch caching-spsbe14
![Page 1: Karine bosch caching-spsbe14](https://reader036.fdocuments.in/reader036/viewer/2022062405/5552f403b4c90584028b4c6e/html5/thumbnails/1.jpg)
Karine BoschSharePoint MVP
Boosting Performance on Publishing sites
#SPSBE
#SPSBE14
![Page 2: Karine bosch caching-spsbe14](https://reader036.fdocuments.in/reader036/viewer/2022062405/5552f403b4c90584028b4c6e/html5/thumbnails/2.jpg)
A big thanks to our sponsorsPlatinum Sponsors
Gold Premium Sponsors
Gold Sponsors
Venue Sponsor
![Page 3: Karine bosch caching-spsbe14](https://reader036.fdocuments.in/reader036/viewer/2022062405/5552f403b4c90584028b4c6e/html5/thumbnails/3.jpg)
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: http://karinebosch.wordpress.com
• Twitter: kbosie
![Page 4: Karine bosch caching-spsbe14](https://reader036.fdocuments.in/reader036/viewer/2022062405/5552f403b4c90584028b4c6e/html5/thumbnails/4.jpg)
Agenda
• Introduction
• Caching data
• Techniques to reduce the page load
• Tools to measure performance
![Page 5: Karine bosch caching-spsbe14](https://reader036.fdocuments.in/reader036/viewer/2022062405/5552f403b4c90584028b4c6e/html5/thumbnails/5.jpg)
Introduction
• Data is stored in SQL Server database
• User requests require data
• 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
No Caching
1. HTTP GET
2. SQL Get Data
3. Data Returned
4. HTTP Response
![Page 6: Karine bosch caching-spsbe14](https://reader036.fdocuments.in/reader036/viewer/2022062405/5552f403b4c90584028b4c6e/html5/thumbnails/6.jpg)
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
![Page 7: Karine bosch caching-spsbe14](https://reader036.fdocuments.in/reader036/viewer/2022062405/5552f403b4c90584028b4c6e/html5/thumbnails/7.jpg)
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
![Page 8: Karine bosch caching-spsbe14](https://reader036.fdocuments.in/reader036/viewer/2022062405/5552f403b4c90584028b4c6e/html5/thumbnails/8.jpg)
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
![Page 9: Karine bosch caching-spsbe14](https://reader036.fdocuments.in/reader036/viewer/2022062405/5552f403b4c90584028b4c6e/html5/thumbnails/9.jpg)
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
![Page 10: Karine bosch caching-spsbe14](https://reader036.fdocuments.in/reader036/viewer/2022062405/5552f403b4c90584028b4c6e/html5/thumbnails/10.jpg)
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"/>
![Page 11: Karine bosch caching-spsbe14](https://reader036.fdocuments.in/reader036/viewer/2022062405/5552f403b4c90584028b4c6e/html5/thumbnails/11.jpg)
Demo
BLOB Cache
![Page 12: Karine bosch caching-spsbe14](https://reader036.fdocuments.in/reader036/viewer/2022062405/5552f403b4c90584028b4c6e/html5/thumbnails/12.jpg)
IIS Cache
• Files stored in _layouts/images folder of WFE
• Files are cached on local browser cache
• Default invalidation period: 365 days
![Page 13: Karine bosch caching-spsbe14](https://reader036.fdocuments.in/reader036/viewer/2022062405/5552f403b4c90584028b4c6e/html5/thumbnails/13.jpg)
Demo
IIS Caching
![Page 14: Karine bosch caching-spsbe14](https://reader036.fdocuments.in/reader036/viewer/2022062405/5552f403b4c90584028b4c6e/html5/thumbnails/14.jpg)
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
![Page 15: Karine bosch caching-spsbe14](https://reader036.fdocuments.in/reader036/viewer/2022062405/5552f403b4c90584028b4c6e/html5/thumbnails/15.jpg)
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
![Page 16: Karine bosch caching-spsbe14](https://reader036.fdocuments.in/reader036/viewer/2022062405/5552f403b4c90584028b4c6e/html5/thumbnails/16.jpg)
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
![Page 17: Karine bosch caching-spsbe14](https://reader036.fdocuments.in/reader036/viewer/2022062405/5552f403b4c90584028b4c6e/html5/thumbnails/17.jpg)
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
• …
![Page 18: Karine bosch caching-spsbe14](https://reader036.fdocuments.in/reader036/viewer/2022062405/5552f403b4c90584028b4c6e/html5/thumbnails/18.jpg)
Demo
Output Cache
![Page 19: Karine bosch caching-spsbe14](https://reader036.fdocuments.in/reader036/viewer/2022062405/5552f403b4c90584028b4c6e/html5/thumbnails/19.jpg)
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
![Page 20: Karine bosch caching-spsbe14](https://reader036.fdocuments.in/reader036/viewer/2022062405/5552f403b4c90584028b4c6e/html5/thumbnails/20.jpg)
Object Cache
• Data is cached based on user rights
• PortalSuperUserAccount
• PortalSuperReaderAccount
• Cache invalidation
• Size: allocate 500KB RAM per site collection
![Page 21: Karine bosch caching-spsbe14](https://reader036.fdocuments.in/reader036/viewer/2022062405/5552f403b4c90584028b4c6e/html5/thumbnails/21.jpg)
Configuring Object Cache
• Set up Portal Super Accounts
• Site collection settings > Site collection object cache
• Tuning options
• Max size
• Flushing
• Cache Invalidation
$wa = Get-SPWebApplication -Identity "<WebApplication>"$wa.Properties["portalsuperuseraccount"] = "<SuperUser>"$wa.Properties["portalsuperreaderaccount"] = "<SuperReader>"$wa.Update()
![Page 22: Karine bosch caching-spsbe14](https://reader036.fdocuments.in/reader036/viewer/2022062405/5552f403b4c90584028b4c6e/html5/thumbnails/22.jpg)
HttpRuntime.Cache Code Sample
• ASP.NET cache class
• Cache key
• Lock before retrieving data from database
• Insert object(s) in cache for a certain period of time
string cacheKey = "BeersOfTheWeek";List<Beer> beerList = null;
// check the cacheobject o = HttpRuntime.Cache.Get(cacheKey);
if (o == null){ object lockHandle = new object(); lock (lockHandle) { // 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;
![Page 23: Karine bosch caching-spsbe14](https://reader036.fdocuments.in/reader036/viewer/2022062405/5552f403b4c90584028b4c6e/html5/thumbnails/23.jpg)
Demo
Object Caching
![Page 24: Karine bosch caching-spsbe14](https://reader036.fdocuments.in/reader036/viewer/2022062405/5552f403b4c90584028b4c6e/html5/thumbnails/24.jpg)
Tools
• Tools to measure performance and page load
• Firebug
• Yslow
• Developer Dashboard
• SPMonitoredScope
![Page 25: Karine bosch caching-spsbe14](https://reader036.fdocuments.in/reader036/viewer/2022062405/5552f403b4c90584028b4c6e/html5/thumbnails/25.jpg)
Developer Dashboard
• Disabled by default
• Can be enabled via
• Object Model
• Stsadm
• PowerShell
• Display levels
• On
• Off
• On Demand
![Page 26: Karine bosch caching-spsbe14](https://reader036.fdocuments.in/reader036/viewer/2022062405/5552f403b4c90584028b4c6e/html5/thumbnails/26.jpg)
SPMonitoredScope
• Included for web parts
• Not included for custom controls
using (SPMonitoredScope breweryBannerScope = new SPMonitoredScope(“Brewery Banner control”)
{ // your code goes here}
![Page 27: Karine bosch caching-spsbe14](https://reader036.fdocuments.in/reader036/viewer/2022062405/5552f403b4c90584028b4c6e/html5/thumbnails/27.jpg)
Demo
Developer Dashboard and SPMonitoredScope
![Page 28: Karine bosch caching-spsbe14](https://reader036.fdocuments.in/reader036/viewer/2022062405/5552f403b4c90584028b4c6e/html5/thumbnails/28.jpg)
Reduce the Page Load
• Suppress JavaScript files and CSS files that are not used in anonymous mode
• Minimize JavaScript files
• Sprites
• Images
• CSS
![Page 29: Karine bosch caching-spsbe14](https://reader036.fdocuments.in/reader036/viewer/2022062405/5552f403b4c90584028b4c6e/html5/thumbnails/29.jpg)
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
![Page 30: Karine bosch caching-spsbe14](https://reader036.fdocuments.in/reader036/viewer/2022062405/5552f403b4c90584028b4c6e/html5/thumbnails/30.jpg)
We need your feedback!
Scan this QR code or visit http://svy.mk/sps2012be
Our sponsors: