Performance tweak: Optimizing StaticFileHandler in EPiServer CMS 5

by: Per Bjurström

The StaticFileHandler that serves files from a VPP is by default configured without a expiration date, or really a negative expiration time. That will cause the browser to, for every request, ask the server if there is a new version of the file, and most of the time EPiServer CMS will return a 304 Not Modified but it still have to look up the file to look at the changed date.

That is all good to make sure editors will always see the latest and greatest content, but it is probably overkill for your visitors. And because most editor are non-identified when they first visit the site we can't have different expiration times for different users because once they are identified we can't just call back the already cached file.

But, when you have a environment where you have separated vistors from editors using multiple sites (which is common in larger configurations) you should tweak this setting.

For example by changing the negative one day from:

<staticFile expirationTime="-1.0:0:0" />

to a couple of hours:

<staticFile expirationTime="4:0:0" />

The nice thing here is that you can have different settings for different directories. Adding a expiration time will get the most effect if you use on a directory that contains images that you often use on your site.

I am also (thanks to Svante) looking into kernel mode caching of the files to get the files delivered with blazing speed right from the kernel of IIS, but that will not be possible without some rewriting of the StaticFileHandler.

18 April 2008


Comments

  1. Per, EPiServer Manager also adds StaticFileHandler as an HttpHandle for a bunch of extensions on root level of the site. At least on my machine it appears that StaticFileHandler only works for files in one VPP and not for real static files even if the code looks like it could. There is also a definied on root level but that apears to have no effect on real static files either. Can you confirm if it is intended that EPiServers Static File Handler should handle ordinary files or not? Regards, Fredrik - http://blog.fredrikhaglund.se
  2. The handlers added on the root level is kind of a workaround, ASP.NET will not add cache-headers for ordinary files when VPP's are added. So, when our StaticFileHandler gets a request for a non-VPP file it just add those headers and pass on the request to ASP.NET. This is a non-issue in IIS 7 where the integrated pipeline fits the EPiServer CMS model much better.
Post a comment    
User verification Image for user verification  
Per Bjurström

About me

I'm a senior developer and architect on the development team in Stockholm and has been with the company since 1999. I live on Södermalm in Stockholm. My main focus areas are new technologies and how we can use them in our product development.

Messenger

Syndications


Archive


Tag cloud

EPiTrace logger