Skip to content

Commit e9a4328

Browse files
committed
chore(cd): Improve SPA caching rules
1 parent 9903266 commit e9a4328

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

web.config

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,27 @@
3232
<rule name="Angular Root Redirect" enabled="true" stopProcessing="true">
3333
<match url="^/?$" />
3434
<action type="Redirect" url="/products/ignite-ui-angular/getting-started" redirectType="Permanent" />
35-
</rule>
35+
</rule>
3636
</rules>
37+
<outboundRules>
38+
<rule name="Cache immutable files" preCondition="IsImmutable">
39+
<match serverVariable="RESPONSE_Cache-Control" pattern=".*" />
40+
<action type="Rewrite" value="public, max-age=31536000, immutable" />
41+
</rule>
42+
<preConditions>
43+
<preCondition name="IsImmutable" logicalGrouping="MatchAny">
44+
<add input="{REQUEST_URI}" pattern="styles-.*\.css$" />
45+
<add input="{REQUEST_URI}" pattern="chunk-.*\.js$" />
46+
<add input="{REQUEST_URI}" pattern="main-.*\.js$" />
47+
<add input="{REQUEST_URI}" pattern="polyfills-.*\.js$" />
48+
<add input="{REQUEST_URI}" pattern="/media/.*" />
49+
</preCondition>
50+
</preConditions>
51+
</outboundRules>
3752
</rewrite>
3853
<staticContent>
39-
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="365.00:00:00" />
54+
<!-- 1 hour public cache for regular static assets -->
55+
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="0.01:00:00" cacheControlCustom="public" />
4056
<remove fileExtension=".json" />
4157
<remove fileExtension=".csv" />
4258
<remove fileExtension=".shp" />
@@ -57,4 +73,12 @@
5773
</customHeaders>
5874
</httpProtocol>
5975
</system.webServer>
76+
<location path="index.html">
77+
<system.webServer>
78+
<staticContent>
79+
<!-- Short-lived cache for index.html -->
80+
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="0.00:05:00" cacheControlCustom="public" />
81+
</staticContent>
82+
</system.webServer>
83+
</location>
6084
</configuration>

0 commit comments

Comments
 (0)