For IIS 6:
<configuration>
<system.webServer>
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="7.00:00:00" />
<remove fileExtension=".js" />
<mimeMap fileExtension=".js" mimeType="application/javascript" />
</staticContent>
</system.webServer>
</configuration>
For IIS 7+:
appcmd.exe set config -section:system.webServer/staticContent
-clientCache.cacheControlMode:UseMaxAge
-clientCache.cacheControlMaxAge:"7.00:00:00"
IIS 6 via metabase.xml:
<IIsCompressionScheme Location ="/LM/W3SVC/Filters/Compression/gzip"
HcCompressionDll="%windir%\system32\inetsrv\gzip.dll"
HcCreateFlags="1"
HcDoDynamicCompression="TRUE"
HcDoStaticCompression="TRUE"
HcDynamicCompressionLevel="9"
HcFileExtensions="htm html txt css js"
HcOnDemandCompLevel="10"
HcPriority="1"
HcScriptFileExtensions="asp aspx dll exe"
/>
Remove machine-specific ETags in IIS 7+:
appcmd set config -section:system.webServer/staticContent
-clientCache.cacheControlCustom:"public"
-clientCache.cacheControlMode:"UseMaxAge"
-clientCache.cacheControlMaxAge:"365.00:00:00"
Key registry tweaks for IIS 6:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\HTTP\Parameters]
"MaxConnections"=dword:0000ffff
"MaxFieldLength"=dword:0000ffff
"MaxRequestBytes"=dword:0000ffff
Complete web.config for IIS 7+ static files:
<configuration>
<system.webServer>
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="365.00:00:00" />
<remove fileExtension=".js" />
<mimeMap fileExtension=".js" mimeType="application/javascript" />
<remove fileExtension=".css" />
<mimeMap fileExtension=".css" mimeType="text/css" />
</staticContent>
<urlCompression doStaticCompression="true" doDynamicCompression="true" />
<httpCompression>
<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
<staticTypes>
<add mimeType="text/*" enabled="true" />
<add mimeType="application/javascript" enabled="true" />
</staticTypes>
</httpCompression>
</system.webServer>
</configuration>
For high-traffic scenarios, consider these IIS 7 adjustments:
%windir%\system32\inetsrv\appcmd.exe set config /section:serverRuntime
/frequentHitThreshold:1
/frequentHitTimePeriod:00:00:30
/frequentHitSamplePeriod:00:00:30
IIS can be effectively configured as a static file server/CDN alternative. Here's how to implement key optimizations:
For IIS 7+ (recommended approach):
<configuration> <system.webServer> <httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files"> <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" /> <dynamicTypes> <add mimeType="text/*" enabled="true" /> <add mimeType="application/javascript" enabled="true" /> <add mimeType="application/x-javascript" enabled="true" /> </dynamicTypes> </httpCompression> <urlCompression doStaticCompression="true" doDynamicCompression="true" /> </system.webServer> </configuration>
For both IIS 6 and 7:
<configuration> <system.webServer> <staticContent> <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="30.00:00:00" /> </staticContent> </system.webServer> </configuration>
IIS automatically handles these by default, but you can customize:
<configuration> <system.webServer> <httpProtocol> <customHeaders> <remove name="ETag" /> <add name="ETag" value="" /> </customHeaders> </httpProtocol> </system.webServer> </configuration>
Key optimizations for high traffic scenarios:
<configuration> <system.webServer> <serverRuntime enabled="true" frequentHitThreshold="1" frequentHitTimePeriod="00:00:10" /> <applicationPool> <recycling logEventOnRecycle="Time, Requests"> <periodicRestart requests="50000" time="00:00:00"> <schedule> <clear /> </schedule> </periodicRestart> </recycling> <processModel idleTimeout="00:00:00" maxProcesses="1" /> </applicationPool> </system.webServer> </configuration>
Additional registry settings for IIS 6 (use regedit):
Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\InetInfo\Parameters] "MaxCachedFileSize"=dword:00001000 "ObjectCacheTTL"=dword:0000001e "MemCacheSize"=dword:00000400
For IIS 7+, use appcmd:
appcmd set config /section:serverRuntime /frequentHitThreshold:1 appcmd set config /section:serverRuntime /frequentHitTimePeriod:00:00:10
Verify your configuration with these tools:
- Fiddler or Chrome DevTools to check response headers
- Webpagetest.org for performance metrics
- IIS Failed Request Tracing for troubleshooting