cancel
Showing results for 
Search instead for 
Did you mean: 

Cache Control - Windows Hosting - web.config

I've been trying to find a way to add Cache-Control to my Windows Hosting.

 

I found an article that states I should use the following code in my web.config file:

<configuration>
   <system.webServer>
      <staticContent>
         <clientCache cacheControlMode="UseExpires"
            httpExpires="Tue, 19 Jan 2038 03:14:07 GMT" />
      </staticContent>
   </system.webServer>
</configuration>

But I already have this piece of code in there:

 

<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="https://{HTTP_HOST}/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

 I have simply placed one part of code after the other, but I am wondering if this is incorrectly done, as my results on Google's PageSpeed Insights hasn't budged, since applying the cache-control to my web.config

 

If anyone can offer any advice, I would much appreciate it.

1 REPLY 1
New

Re: Cache Control - Windows Hosting - web.config

I can only think of misplacement of the code.  For example, keep everything with the <webServer> attribute instead of creating two <configuration> attribute declarations. 

 

<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="https://{HTTP_HOST}/{R:1}" />
</rule>
</rules>
</rewrite>
 <staticContent>
         <clientCache cacheControlMode="UseExpires"
            httpExpires="Tue, 19 Jan 2038 03:14:07 GMT" />
 </staticContent>

</system.webServer>
</configuration>