gpt4 book ai didi

http - 通过powershell在IIS上设置文件html响应头缓存控制

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:25:55 25 4
gpt4 key购买 nike

我正在尝试将 IIS 上的 http 响应 header 上的 cache-control: max-age 设置为特定文件。我正在尝试使用 PowerShell 脚本或 CMD 命令来执行此操作。我可以这样做吗?如果是,怎么办?

最佳答案

来不及回答这个问题,可能对那些仍在寻找解决方案的人有帮助。

我在 Powershell 中使用了“appcmd.exe”。以下是我在 Powershell 中的使用方式:

# path to appcmd.exe
$appCmd = "C:\windows\system32\inetsrv\appcmd.exe"

# Path to the folder where we want to set the cache max-age
# in this case its a "scripts" folder in "Default Web Site" site
$env:folderPathScripts = "Default Web Site/scripts"

# sets the max age to 2 days
& $appCmd --% set config "%folderPathScripts%" -section:staticContent -clientCache.cacheControlMode:UseMaxAge -clientCache.cacheControlMaxAge:2.00:00:00

#To disable the cache
& $appCmd --% set config "%folderPathScripts%" -section:staticContent -clientCache.cacheControlMode:DisableCache

我提到了以下链接:

https://forums.iis.net/t/1174801.aspx?How+to+Remove+and+Add+custom+headers+convert+from+appcmd

https://technet.microsoft.com/en-us/library/jj635852(v=ws.11).aspx

https://technet.microsoft.com/en-us/library/cc770661(v=ws.10).aspx

关于http - 通过powershell在IIS上设置文件html响应头缓存控制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40884327/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com