Files being cached too aggressively in R2

by: Per Bjurström

Update: This problem has been fixed in CMS 5 R2 SP2.

You may want to read another article first for some background on the settings I’ll be talking about in Http Caching strategies: VPP Files.

Since EPiServer CMS 5 R2 was released we’ve found an unintentional change in the behavior of StaticFileHandler that serves files (bug #21556). The StaticFileHandler serves files from VPP-folders on IIS 7 and serves files from all locations on IIS 6 (since we require the wildcard-mapping).

One of the features we wanted to enable in R2 was kernel mode caching of files on both IIS 6 and IIS 7 for high-performance sites (based on partner/customer feedback). But, we did not intend to enable the ASP.NET output cache for files, turns out that these two features go hand in hand.

The output cache causes a problem that files are not getting updated until the server cache expires which can be quite annoying. This only happens for files where expirationTime in web.config is set to a positive value. The workaround is to force cacheControl to “private” (or set expirationTime to a negative value):

<staticFile  expirationTime="1.0:0:0" cacheControl="private" />

We will be adding a new attribute on staticFile in the next release called enableOutputCache if you still want the output cache but we feel that this aggressive caching should be disabled by default even when upgrading. Especially since there are better ways of doing kernel caching in IIS 7, see my other post.

Files gone missing ?

There have been some reports on truncated files which seem to be caused by this aggressive cache, changing the configuration described above does seem to fix this problem in my tests. The actual bug causing truncated files have been sent to Microsoft, read more in the forums if you are interested.

13 March 2009


Comments

Post a comment    
User verification Image for user verification  
EPiTrace logger