A few months ago we launched a new website on SharePoint 2010. One of my main foci on the project was performance and caching is one of the most effective ways to achieve that for a WCM solution. We enabled Output, Object and BLOB caching, configured exclusions as necessary and were quite pleased with the results, especially since issues with BLOB Caching in 2007 have been resolved in 2010.
A few weeks later I was demonstrating these approaches when it was pointed out that we were getting lots of 304 responses. They occurred with each request for a previously-downloaded BLOB Cached asset (more detail added below). Basically, I overlooked the max-age attribute in the BLOB Cache web.config settings. By default, this attribute isn’t present in the web.config file and I simply missed it. Adding this attribute eliminated the 304 results and the caching configuration was complete. Or so we thought.
Edit to provide more detail on the 304 status and Max-Age
A 304 response is a File Not Modified status (not an error), in this case indicating that the browser is making (potentially) surplus checks for each previously-downloaded BLOB Cached file. The max-age attribute gives the file a lifetime in the client’s browser cache in order to reduce these update checks. To be clear, the BLOB Cache stores large objects on web servers to reduce database traffic, but those objects can be served with a max-age attribute that will determine the object’s lifetime in the client’s browser cache. A max-age value of “14400″ means that browsers will cache the file for four hours before checking for an update. This means that updates to BLOB Cached content may become stale if this value is set too high. A common value would be “86400″ (24 hours) but we were satisfied with the balance at four hours. In our case, making this update has not yielded a perceptible increase in performance with the current levels of traffic, but it’s the sort of thing you want to set appropriately in order to optimise things and to allow the environment to scale.
So… yesterday we were told that the 304 results were still appearing after making this change some time ago. When I started testing it I quickly confirmed there were loads of 304 results when I requested BLOB Cached assets for a second time. I tried clearing my browser caches, closed down all browsers and tested in multiple browsers but couldn’t get to the bottom of it, as the BLOB Cache max-age attribute was definitely set in the web.config file.
A bit stumped, I asked knowledgeable people for help. No luck. To recap, this was the full context:
- The Caching column in Fiddler revealed that the max-age attribute was set. I could see the specified value coming through as “public, max-age=14400″. If I changed the value to 86400, the value would get updated on refresh. Clearly the web.config attributes were served correctly.
- In IE I noticed the “Pragma: no-cache” header. In Firefox I saw “Cache-Control: max-age=0″. I couldn’t figure out where these headers were coming from and suspected that was the source of the problem.
Eventually I pinpointed that this behaviour only occurred when I hit F5 or pressed Refresh in the browser. If I typed in the address or clicked on a link I would just get the HTTP 200 results as I would expect. If I hit CRTL+F5, everything would get downloaded afresh (lots of 200s), also as expected. I asked Chris O’Brien if he had any ideas why this would only happen with F5/Refresh and he pointed out that this is exactly what does happen, and a lot of people don’t realise it. Excellent! Learned something new today. Either max-age or F5 could be the cause of the 304 results, but F5 gives a false impression of what users would see when accessing an asset for the second time, unless those users are pressing Refresh a lot. If they’re browsing normally, they’ll in fact get a 200 result. If max-age isn’t set, the 304 results will accurately reveal that users are checking to see if the BLOB Cached file is updated every time they try to access it. In some cases this will be desirable, but it definitely adds up quickly.
Pressing on, I wanted to get to the bottom of what else might be different with F5/Refresh and figure out what was up with those Pragma/Cache-Control headers. It turns out, it’s the F5/Refresh itself that generates the Pragma/Cache-Control header. All mysteries solved! Many thanks to Chris for his help with this. Hope this can help someone else.
On TwitterMy Tweets
- JohnLong on Adding Drivers to Windows Deployment Services Boot Images
- Boog on How to enable Lync audio within a Remote Desktop session
- Tristan Watkins on How to enable Lync audio within a Remote Desktop session
- Perl on How to enable Lync audio within a Remote Desktop session
- ShamrockSoft on No Lossless Audio With Zune
- Administrivia (1)
- Authentication (10)
- Business Continuity (2)
- Client applications (17)
- Consultancy and Design (17)
- Hardware (9)
- IT Management (12)
- Miscellaneous (5)
- Mobile (3)
- Networking (18)
- Office 365 Grid (3)
- Performance (26)
- Power (2)
- Security (20)
- SharePoint (76)
- Unified Communications (3)
- Virtualisation (30)
- Windows (53)
TagsActive Directory administration Amazon Web Services ASUS binding BLOB Caching certificates Claims Cloud DCOM Dell development DNS EC2 Graphics Hyper-V IaaS ICS IIS Information Rights Management Intel IRM Lync NUMA PowerShell RMS SAML Search SEO Service Application SharePoint 2007 SharePoint 2010 SLAT STSADM Timer Job User Information User Profile Virtual Machine VMWare w3wp Windows 7 Windows Deployment Services Windows Server 2008 R2 Workgroup
Archives by Month