Skip to content

Commit 2361ca7

Browse files
committed
chore(cd): Improve caching in crmapp web.config
1 parent 7574281 commit 2361ca7

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

projects/app-crm/web.config

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,26 @@
3030
<action type="Rewrite" url="/angular-demos/" />
3131
</rule>
3232
</rules>
33+
<outboundRules>
34+
<rule name="Cache immutable files" preCondition="IsImmutable">
35+
<match serverVariable="RESPONSE_Cache-Control" pattern=".*" />
36+
<action type="Rewrite" value="public, max-age=31536000, immutable" />
37+
</rule>
38+
<preConditions>
39+
<preCondition name="IsImmutable" logicalGrouping="MatchAny">
40+
<add input="{REQUEST_URI}" pattern="styles-.*\.css$" />
41+
<add input="{REQUEST_URI}" pattern="chunk-.*\.js$" />
42+
<add input="{REQUEST_URI}" pattern="main-.*\.js$" />
43+
<add input="{REQUEST_URI}" pattern="polyfills-.*\.js$" />
44+
<add input="{REQUEST_URI}" pattern="/media/.*" />
45+
</preCondition>
46+
</preConditions>
47+
</outboundRules>
3348
</rewrite>
3449
<staticContent>
35-
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="365.00:00:00" />
50+
<!-- 1 hour public cache for regular static assets -->
51+
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="0.01:00:00" cacheControlCustom="public" />
52+
3653
<remove fileExtension=".json" />
3754
<remove fileExtension=".csv" />
3855
<remove fileExtension=".shp" />
@@ -53,4 +70,12 @@
5370
</customHeaders>
5471
</httpProtocol>
5572
</system.webServer>
73+
<location path="index.html">
74+
<system.webServer>
75+
<staticContent>
76+
<!-- Short-lived cache for index.html -->
77+
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="0.00:05:00" cacheControlCustom="public" />
78+
</staticContent>
79+
</system.webServer>
80+
</location>
5681
</configuration>

web.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
<staticContent>
5454
<!-- 1 hour public cache for regular static assets -->
5555
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="0.01:00:00" cacheControlCustom="public" />
56+
5657
<remove fileExtension=".json" />
5758
<remove fileExtension=".csv" />
5859
<remove fileExtension=".shp" />

0 commit comments

Comments
 (0)