首页 > 解决方案 > 使用 powershell 更新 iis 中的缓存值

问题描述

我正在尝试使用下面的 powershell 脚本更新 IIS 中的缓存值,但无法帮助获得准确的输出。有人可以帮我纠正这个问题。

在此处输入图像描述

Import-Module WebAdministration

Set-WebConfigurationProperty -filter "/system.webServer/staticContent/clientCache" -name cacheControlMode -value "UseExpires"
Set-WebConfigurationProperty -filter "/system.webServer/staticContent/clientCache" -name cacheControlMaxAge -value "02:00:00"
Set-WebConfigurationProperty -filter "/system.webServer/staticContent/clientCache" -name httpExpires -value "Tue, 20 Feb 2020 00:00:00 GMT"

标签: powershelliis

解决方案


尝试使用 PowerShell 对象表示法链接。您可能需要关闭并打开 IIS 管理器才能看到更改。以下是它为我工作的方式

Set-WebConfiguration `
    -PSPath IIS:\Sites\Default\<your web application> `
    -filter '/system.webServer/staticContent/clientCache' -Value (@{cacheControlCustom=""})

推荐阅读