Monday, October 4, 2010

A while back I blogged about a service that would go fetch Natural Gas Prices, the price of Oil and Stock Quotes from Yahoo. The information that is returned from BizTalk is surfaced in an Xcelsius dashboard along with a lot of other business critical data from SAP. Our executive team accesses this information from a web part in SharePoint site. As people launch their browsers, they see the Stock Quotes and other commodity prices get updated. Since this is a dashboard, people will view the data for a few minutes and then close their browser. This type of user behavior never uncovered a flaw in the application. It is not like someone sat on the dashboard all day long waiting for the stock price to change.

A request came in to turn this Dashboard into a Windows 7 widget. Once this widget was in place, we uncovered that the stock quotes were not being updated. The Widget simply acts as a container for the dashboard. So we dug out Fiddler and could determine that the BizTalk service was not being called on a regular interval. The reason? Caching. There was no cache command or expiration date sent on the HTTP header going back to the dashboard so it would not be called on a regular basis. Since this Widget does not get restarted like a Web Browser does, the stock quotes would remain static for the duration of a user’s desktop session.

To avoid this situation, I needed to provide an explicit command in a Message Assignment Shape to prevent my responses from being cached:

Since the client was instructed not to cache the response, it would now go ahead and call the service when it goes to refresh the rest of its data.

There are many options that you can set within the HTTP Header. For example, if you wanted to expire content every 2 minutes, you could set your header to Cache-Control: max-age=120. If you are interested in what other features can be set in an HTTP Header, I recommend checking out this site.