开发者

Control Caching in IIS7 from C#

开发者 https://www.devze.com 2023-03-17 21:54 出处:网络
I have situation described bellow: In CMS was implemented two presentation serverwhich aren\'t on same machine. Client want to enable IIS caching only on one machine, but changing manually web.config

I have situation described bellow: In CMS was implemented two presentation server which aren't on same machine. Client want to enable IIS caching only on one machine, but changing manually web.config isn't suggested. So I am planning to make some C# code which will make changes in web.config in order to ensure proper cache settings. Is i开发者_Go百科t possible or exist any other solution ( change other settings, edit other files...) for the problem?


"You can configure the element at the server level in the ApplicationHost.config file or at the site, application, or at the directory level in a Web.config file."

If you have physical access to the server you can run from the console appcmd.exe:

appcmd.exe set config -section:system.webServer/caching /+"profiles.[extension='asp',policy='CacheUntilChange',kernelCachePolicy='CacheUntilChange']" /commit:apphost

Check this link: http://www.iis.net/ConfigReference/system.webServer/caching

EDITED

The first answer to this question says how to configure caching at folder level, the 2nd answer for file level:

How to configure static content cache per folder and extension in IIS7?

If you didn't specify any caching rules at file or folder level, disabling global caching should do it.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号