Posted on 15. April 2014

Fiddler2: The tool that gives you Superpowers – Part 4

This post is the fourth and final post in the series 'Fiddler – the tool that gives you superpowers!'

Ice Man

Perhaps Ice Man is the most tenuous super power claim but it's regarding a very important topic – HTTP Caching. Having a good caching strategy is key to having good client performance and not over-loading your network with unnecessary traffic. Luckily Dynamics CRM gives us an excellent caching mechanism – but there are situations where it can be accidently unknowingly bypassed:

  1. Not using relative links in HTML webresources
  2. Loading scripts/images dynamically without using the cache key directory prefix
  3. Not using the $webresource: prefix in ribbon/sitemap xml.

Luckily we can use Fiddler to keep our servers running ice cold by checking that files that are not being cached when they should be. There are types of caching that you need to look for:

Absolute expiration

These web resources will not show in Fiddler at all because the browser has located a cached version of the file with an absolute cache expiration date and so it doesn't need to request anything from the server. By default CRM provides an expiration date of 1 year from the date requested, but if the web resource is updated on the server then the Url changes and so a new version is requested. This is why you see a request similar to /OrgName/%7B635315305140000046%7D/WebResources/somefile.js. Upon inspection of the response you will see an HTTP header similar to:

HTTP/1.1 200 OK
Cache-Control: public
Content-Type: text/jscript
Expires: Tue, 14 Apr 2015 21:18:35 GMT

Once the web resource is downloaded on the client it is requested again until April 14 2015 unless a new version is published where CRM will request the file using a new cache key (the number between the Organization name and the WebResources directory). You can read more about this mechanism on my post about web resource caching.

ETAG Cached files

These resource are usually images and static JavaScript files that are assigned an ETAG value by the server. When the resource changes on the server it is assigned a different ETAG value. When the browser requests the file it sends the previous ETAG value if it hasn't been modified then the server responds with a 304 response meaning that the browser can use the local cached file.

Files that use ETAG caching will show in grey in Fiddler with a response code of 304:

During your web resource testing it is a good idea to crack open Fiddler and perform your unit tests – you should look for any non-304 requests for files that don't need to be downloaded every time they are needed.

Another way to ensure that your servers are running cool as ice is to look at the request execution length. Occasionally code can be written that accidently returns much too much data than required - perhaps all attributes are included or a where criteria is missing. These issues don't always present themselves when working on a development system that responds to queries very quickly, but as soon as you deploy to a production system with many users and large datasets, you start to see slow performance.

There are a number of ways you can test for this using Fiddler:

Visualise Request Times

The order in which your scripts, SOAP and REST requests are executed in can greatly affect the performance experienced by the user and so you can use Fiddler's Time line visualizer to see which requests are running is series and which are running in parallel. It also shows you the length of time the requests are taking to download so that you can identify the longest running requests and focus your optimisation efforts on those first.

  •  

    Simulate Slow Networks

    If you know that your users will be using a slow network to access CRM or you would just like to see how the application responds when the requests start to take longer because of larger datasets you can tell fiddler to add an artificial delay into the responses. To do this you can use the built in Rules->Performance->Simulate Modem Speeds but this usually results in an unrealistically slow response time. If you are using Auto Responders you can right-click on the Rule and use set Latency – but this won't work for Organization Service/REST calls. The best way I've found is to use the Fiddler Script:

    1) Select the 'Fiddler Script' Tab

    2) Select 'OnBeforeRequest' in the 'Go to' drop down

    3) Add the following line to the OnBeforeRequest event handler.

    This will add a 50 millisecond delay for every kB requested from the server which assuming there was no time server time would result in ~160 kbps downloads.

    If you've not used Fiddler for your Dynamics CRM Development yet I hope these posts are enough to convince you that you should give it a try – I promise you'll never look back!

    @ScottDurow

    Comments

    Scott Durow's Dynamics CRM Blog Scott Durow's Dynamics CRM Blog
    9:34 PM on Tuesday, April 15, 2014

    Fiddler2: The tool that gives you Superpowers - Part 2

    This post is the second post in the series 'Fiddler – the tool that gives you superpowers!'

    Hosk's Dynamic CRM 2011 Blog Hosk's Dynamic CRM 2011 Blog
    3:31 PM on Friday, April 25, 2014

    Hosk’s Top CRM 2013 articles of the week 25th April 2014

    First I like to start on a high note with a celebrity thumbs up for surviving another week everyone,

    Hosk's Dynamic CRM 2011 Blog Hosk's Dynamic CRM 2011 Blog
    12:02 PM on Friday, May 30, 2014

    Hosk’s Top CRM 2013 articles of the week 30th May 2014

    I have been on holiday this week, so I didn’t have my usual collection of articles but I have cobbled

    Hosk's Dynamic CRM 2011 Blog Hosk's Dynamic CRM 2011 Blog
    9:50 PM on Thursday, June 05, 2014

    Hosk’s Top CRM 2013 articles of the week 30th May 2014

    I have been on holiday this week, so I didn’t have my usual collection of articles but I have cobbled

    trackback Develop 1 Limited Blog
    6:28 PM on Friday, June 06, 2014

    Monitor, Monitor, Monitor

    Monitor, Monitor, Monitor

    Scott Durow's Dynamics CRM Blog Scott Durow's Dynamics CRM Blog
    4:00 PM on Wednesday, July 09, 2014

    Monitor, Monitor, Monitor

    I once heard someone say that "the great thing about Dynamics CRM is that it just looks after itself"

    Hosk's Dynamic CRM  Blog Hosk's Dynamic CRM Blog
    3:17 PM on Friday, January 02, 2015

    Hosk’s Top CRM Articles of the Year 2014

    Waking up early, isn’t a problem I have two young children (1 and 3) who are particularly effective

    Comments are closed