---
title: Configure file caching
slug: cms-11/dev-docs/configuring-caching-of-files
docTags: 
createdAt: 2026-07-22T19:45:20.282Z
---

You can add cache information to the response headers at the request of **static files** so the client can cache files and not have the web server serve at each request, significantly reducing the total request time for a client.

You can set the `<staticFile>` section of `web.config` on a location level. For the `<staticFile>` section to be available, you have to add it to `<configSections>` first:

```xml
<section name="staticFile" 
         type="EPiServer.Framework.Configuration.StaticFileSection, EPiServer.Framework.AspNet" 
         allowLocation="true" />
```

This  `<staticFile>` section controls the `Expires` and `Cache-Control` cache header directives. You can set different expiration times depending on the path to the static file. The `StaticFileHandler` that delivers files from Virtual Path Providers and by the media system in CMS use the `staticFile` configuration. Files delivered by IIS, such as CSS and other resources on the website, are configured using [standard IIS configuration settings](http://www.iis.net/configreference/system.webserver/staticcontent/clientcache).

```xml
<configuration>
    
    <!--Configures expiration for files in CMS/VPP-->
    <staticFile expirationTime="12:0:0" />
    
    <!--Configures expiration in IIS-->
    <system.webServer>
       <!--Configures client headers for static files from IIS-->
       <staticContent>
           <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="1.00:00:00"></clientCache>
       </staticContent>
       <!--Configures output and kernel caching for ALL images (both CMS and IIS)-->
       <caching>
          <profiles>
            <add extension=".gif" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" duration="0.00:01:00" location="Any" />
            <add extension=".png" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" duration="0.00:01:00" location="Any" />
            <add extension=".js" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" duration="0.00:01:00" location="Any" />
            <add extension=".css" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" duration="0.00:01:00" location="Any" />
            <add extension=".jpg" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" duration="0.00:01:00" location="Any" />
            <add extension=".jpeg" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" duration="0.00:01:00" location="Any" />
          </profiles>
       </caching>
    </system.webServer>
    </configuration>
```
