Created
September 17, 2015 06:01
-
-
Save IDisposable/949f47c6b1d165038200 to your computer and use it in GitHub Desktop.
Enabling static file compression on IIS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<configuration> | |
<system.webServer> | |
<validation validateIntegratedModeConfiguration="false" /> | |
<urlCompression doStaticCompression="true" doDynamicCompression="true" dynamicCompressionBeforeCache="false" /> | |
<!--minification requires dynamicCompressionBeforeCache off, order of operations error?--> | |
<httpCompression noCompressionForHttp10="false" noCompressionForProxies="false" staticCompressionIgnoreHitFrequency="true" /> | |
<!--If your IIS server has this unlocked, uncomment | |
<serverRuntime frequentHitThreshold="1" frequentHitTimePeriod="00:00:10" enabled="true" /> | |
--> | |
<staticContent> | |
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="49.00:00:00" /> | |
<remove fileExtension=".woff2" /> | |
<mimeMap fileExtension=".woff2" mimeType="application/font-woff2" /> | |
</staticContent> | |
<caching enabled="true"> | |
<profiles> | |
<add extension=".ico" policy="CacheUntilChange" kernelCachePolicy="DontCache" duration="49.00:00:00" location="Downstream" varyByQueryString="*" varyByHeaders="Accept-Encoding" /> | |
<add extension=".png" policy="CacheUntilChange" kernelCachePolicy="DontCache" duration="49.00:00:00" location="Downstream" varyByQueryString="*" varyByHeaders="Accept-Encoding" /> | |
<add extension=".jpg" policy="CacheUntilChange" kernelCachePolicy="DontCache" duration="49.00:00:00" location="Downstream" varyByQueryString="*" varyByHeaders="Accept-Encoding" /> | |
<add extension=".gif" policy="CacheUntilChange" kernelCachePolicy="DontCache" duration="49.00:00:00" location="Downstream" varyByQueryString="*" varyByHeaders="Accept-Encoding" /> | |
<add extension=".eot" policy="CacheUntilChange" kernelCachePolicy="DontCache" duration="49.00:00:00" location="Downstream" varyByQueryString="*" varyByHeaders="Accept-Encoding" /> | |
<add extension=".ttf" policy="CacheUntilChange" kernelCachePolicy="DontCache" duration="49.00:00:00" location="Downstream" varyByQueryString="*" varyByHeaders="Accept-Encoding" /> | |
<add extension=".woff" policy="CacheUntilChange" kernelCachePolicy="DontCache" duration="49.00:00:00" location="Downstream" varyByQueryString="*" varyByHeaders="Accept-Encoding" /> | |
<add extension=".woff2" policy="CacheUntilChange" kernelCachePolicy="DontCache" duration="49.00:00:00" location="Downstream" varyByQueryString="*" varyByHeaders="Accept-Encoding" /> | |
<add extension=".htc" policy="CacheUntilChange" kernelCachePolicy="DontCache" duration="49.00:00:00" location="Downstream" varyByQueryString="*" varyByHeaders="Accept-Encoding" /> | |
<add extension=".svg" policy="CacheUntilChange" kernelCachePolicy="DontCache" duration="49.00:00:00" location="Downstream" varyByQueryString="*" varyByHeaders="Accept-Encoding" /> | |
<add extension=".css" policy="CacheUntilChange" kernelCachePolicy="DontCache" duration="49.00:00:00" location="Downstream" varyByQueryString="*" varyByHeaders="Accept-Encoding" /> | |
<add extension=".js" policy="CacheUntilChange" kernelCachePolicy="DontCache" duration="49.00:00:00" location="Downstream" varyByQueryString="*" varyByHeaders="Cookies, Accept-Encoding" /> | |
<add extension=".xml" policy="CacheUntilChange" kernelCachePolicy="DontCache" duration="49.00:00:00" location="Downstream" varyByQueryString="*" varyByHeaders="Accept-Encoding" /> | |
<add extension=".txt" policy="CacheUntilChange" kernelCachePolicy="DontCache" duration="49.00:00:00" location="Downstream" varyByQueryString="*" varyByHeaders="Accept-Encoding" /> | |
</profiles> | |
</caching> | |
<modules runAllManagedModulesForAllRequests="true" /> | |
<httpProtocol> | |
<customHeaders> | |
<clear /> | |
<remove name="Access-Control-Allow-Origin" /> | |
<add name="Access-Control-Allow-Origin" value="*" /> | |
<remove name="Access-Control-Allow-Headers" /> | |
<add name="Access-Control-Allow-Headers" value="Content-Type" /> | |
</customHeaders> | |
</httpProtocol> | |
</system.webServer> | |
</configuration> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you're in a bare IIS site, you might have to be explicit about the modules you want to run, also make sure your vary-bys match your usage... these are for no-cookie, etc.
Lastly you may need to unlock the serverRuntime element of your machine configuration, I do this with these commands in a
cmd
file