使用PowerShell在IIS中更新缓存值

时间:2020-01-30 14:22:46

标签: powershell iis

am尝试使用下面的powershell脚本更新IIS中的缓存值,但无助于获得准确的输出。有人可以帮我改正吗。

enter image description here

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"

1 个答案:

答案 0 :(得分:0)

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

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