Created
September 12, 2019 15:09
-
-
Save lynt-smitka/95b7cc961c71fdd219a94fe44d3c8764 to your computer and use it in GitHub Desktop.
IIS webp
This file contains 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> | |
<rewrite> | |
<rules> | |
<rule name="webp"> | |
<match url="(.+)\.(jpe?g|png)$" ignoreCase="false" /> | |
<conditions logicalGrouping="MatchAll"> | |
<add input="{HTTP_ACCEPT}" pattern="image/webp" ignoreCase="false" /> | |
<add input="{DOCUMENT_ROOT}/{R:1}.webp" matchType="IsFile" /> | |
</conditions> | |
<action type="Rewrite" url="{R:1}.webp" logRewrittenUrl="true" /> | |
<serverVariables> | |
<set name="ACCEPTS_WEBP" value="true" /> | |
</serverVariables> | |
</rule> | |
</rules> | |
<outboundRules> | |
<rule name="Set Vary header" preCondition="IsWebp"> | |
<match serverVariable="RESPONSE_Vary" pattern=".*" /> | |
<action type="Rewrite" value="Accept" /> | |
</rule> | |
<preConditions> | |
<preCondition name="IsWebp"> | |
<add input="{ACCEPTS_WEBP}" pattern="true" ignoreCase="false" /> | |
</preCondition> | |
</preConditions> | |
</outboundRules> | |
</rewrite> | |
<staticContent> | |
<mimeMap fileExtension=".webp" mimeType="image/webp" /> | |
</staticContent> | |
</system.webServer> | |
</configuration> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment