It is possible to configure which cache information is added to the response headers at request of static files. This can be used so files can be cached by the client and not served by the web server at each request meaning the total request time for a client can be reduced significantly.

web.config settings

The setting in web.config that controls the cache header directives "Expires" and "Cache-Control" is the configuration section staticFile that is allowed to be set on location level. This means it is possible to set different expiration times depending on the path to the static file.

Sample where an Expires time is set globally for the site and where that expiration time is overridden in a sub path.




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


    <location path="Documents">



                   <add path="*" verb="GET,HEAD" type="EPiServer.Web.StaticFileHandler, EPiServer" validate="true"/>      



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




The component that is responsible for delivering static files is EPiServer.Web.StaticFileHandler. It is possible to write an own custom static file handler (must implement System.Web.IHttpHandler) that can serve static files. E.g. to add response headers an alternative is to let the custom handler extend EPiServer.Web.StaticFileHandler and e.g. override method SetCachePolicy to add response headers for UnifiedFiles. To register a custom httpHandler it should be configured in the httpHandlers section (either globally or for a specific location depending on the wanted scope).