I host an angular frontend inside an Azure App Service on Linux. Stack is Node 12. In order to enable the response headers "Cache-Control" for the static files I have added the line
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="3.00:00:00" />
inside the Web.config file as suggested in the microsoft documentation here
The Web.config file looks like this:
<configuration>
<system.webServer>
<handlers>
<clear />
<add
name="StaticFile"
path="*" verb="*"
modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule"
resourceType="Either"
requireAccess="Read" />
</handlers>
<staticContent>
<mimeMap fileExtension=".json" mimeType="application/json" />
<mimeMap fileExtension=".*" mimeType="application/octet-stream" />
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="3.00:00:00" />
</staticContent>
<rewrite>
<rules>
<rule name="redirect all requests" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" pattern="" ignoreCase="false" />
</conditions>
<action type="Rewrite" url="index.html" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
Unfortunately the headers are not set correctly. Is there something wrong with the Web.config file? Does the Azure App Service on Linux have to do something with it?
PaaS
services, we can't do more settings. If the.htaccess
is modified and the attempt is invalid, the hard code can only be used to implementcache-control
every time a request is sent. – Jason Pan