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

Http 通过powershell在IIS上设置文件的html响应头缓存控制,http,iis,header,max,response,Http,Iis,Header,Max,Response,我正在尝试将IIS上http响应头上的cache control:max age设置为特定文件。我正在尝试使用PowerShell脚本或CMD命令来实现这一点。我可以这样做吗?如果是,如何回答?回答这个问题太晚了,可能对那些仍在寻找解决方案的人有所帮助 我在Powershell中使用了appcmd.exe。 下面是我在Powershell中的使用方式: # path to appcmd.exe $appCmd = "C:\windows\system32\inetsrv\appcmd.exe"

我正在尝试将IIS上http响应头上的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

我提到了以下链接:


回答这个问题太晚了,这可能对那些仍在寻找解决方案的人有所帮助

我在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

我提到了以下链接: