<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <!-- Customize HTTP Headers -->
        <httpProtocol>
            <customHeaders>
                <remove name="X-Powered-By" />
                <!-- Don't cache by default -->
                <remove name="Cache-Control" />
                <add name="Cache-Control" value="max-age=0, no-cache, no-store" />
            </customHeaders>
        </httpProtocol>

        <!-- Rewrite Rules -->
        <rewrite>
            <outboundRules>
                <rule name="Set optional HSTS header">
                    <match serverVariable="RESPONSE_Strict_Transport_Security" pattern=".*" />
                    <conditions>
                        <!-- Only send HSTS over https. -->
                        <add input="{HTTPS}" pattern="on" ignoreCase="true" />
                        <!-- Don't send HSTS for the entire bankid.com domain. -->
                        <add input="{HTTP_HOST}" pattern="^bankid.com" negate="true" />
                    </conditions>
                    <action type="Rewrite" value="max-age=31536000; includeSubDomains" />
                </rule>

                <rule name="Enable caching for other js files">
                    <match serverVariable="RESPONSE_Cache-Control" pattern=".*" />
                    <conditions>
                        <add input="{REQUEST_FILENAME}" pattern="\.(js)$" />
                    </conditions>
                    <action type="Rewrite" value="public, max-age=120, s-maxage=120" />
                </rule>

                <rule name="Enable caching for alert.js">
                    <match serverVariable="RESPONSE_Cache-Control" pattern=".*" />
                    <conditions>
                        <add input="{REQUEST_FILENAME}" pattern="alert\.js$" />
                    </conditions>
                    <action type="Rewrite" value="public, max-age=1800, s-maxage=1800" />
                </rule>
            </outboundRules>
        </rewrite>

        <!-- Explicitly Disable Directory Browsing -->
        <directoryBrowse enabled="false" />
        <security>
          <requestFiltering>
            <verbs allowUnlisted="false">
              <add verb="GET" allowed="true" />
              <add verb="HEAD" allowed="true" />
              <add verb="POST" allowed="true" />
            </verbs>
          </requestFiltering>
        </security>
    </system.webServer>
</configuration>
