Skip to content

Instantly share code, notes, and snippets.

@lynt-smitka
Created September 12, 2019 15:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lynt-smitka/95b7cc961c71fdd219a94fe44d3c8764 to your computer and use it in GitHub Desktop.
Save lynt-smitka/95b7cc961c71fdd219a94fe44d3c8764 to your computer and use it in GitHub Desktop.
IIS webp
<?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