Reputation: 13182
I want to setup disk cache for reverse proxy responses for forwarded requests. I expect all requests to http://localhost:88/ to be forwarded to https://stackoverflow.com/ (as an example) with following rewrite rule:
<rule name="ReverseProxy1" stopProcessing="true">
<match url="(.*)" />
<action type="Rewrite" url="https://stackoverflow.com/{R:1}" />
</rule>
Which works perfectly fine.
And I want all responses from https://stackoverflow.com/ to be cached on disk. I have following setup in applicationHost.config:
<diskCache scavengerInterval="00:05:00">
<driveLocation path="C:\inetpub\temp\cache" maxUsage="0" />
<compression enabled="true">
<add mimeType="text/*" enabled="true" />
<add mimeType="message/*" enabled="true" />
<add mimeType="application/x-javascript" enabled="true" />
<add mimeType="application/javascript" enabled="true" />
</compression>
<sharedDriveLocation path="" />
</diskCache>
<proxy enabled="true" httpVersion="PassThrough" reverseRewriteHostInResponseHeaders="true">
<cache requestConsolidationEnabled="true" queryStringHandling="Accept" validationInterval="00:01:00" />
</proxy>
<rewrite>
<globalRules>
<rule name="ARR_CacheControl_b17f5877-33f6-4bed-be49-f3c07a38cfef" enabled="true" patternSyntax="Wildcard">
<match url="*" />
<serverVariables>
<set name="ARR_CACHE_CONTROL_OVERRIDE" value="1,max-age=1800" />
</serverVariables>
<conditions>
<add input="{HTTP_HOST}" pattern="stackoverflow.com" />
</conditions>
</rule>
</globalRules>
</rewrite>
Unfortunately disk cache is never hit. I can tell it by examining IIS Log with X-ARR-CACHE-HIT=0 entries. And cache folder is always empty. The folder was created by IIS manager UI and I provided access rights to Application Pool identity to this folder, so I assume that the problem is not in access rights to cache folder.
Did I miss anything? Looking for a solution in internet didn't give me any results so any input is very appreciated.
Upvotes: 2
Views: 3526
Reputation: 13182
I found out that the problem was that the Vary response header is present in SO response. And based on the reply on IIS forums ARR doesn't support caching when there is a Vary header in response.
Upvotes: 3