1
我试图将IIS上的http响应头上的缓存控制:max-age设置为特定文件。我正在尝试使用PowerShell脚本或CMD命令来做到这一点。我可以这样做吗?如果是的话,怎么样?通过powershell在IIS上设置文件的html响应头缓存控制
我试图将IIS上的http响应头上的缓存控制:max-age设置为特定文件。我正在尝试使用PowerShell脚本或CMD命令来做到这一点。我可以这样做吗?如果是的话,怎么样?通过powershell在IIS上设置文件的html响应头缓存控制
对于那些仍在寻找解决方案的人来说,回答这个问题还为时过早。
我在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