asp.net 中设置静态内容缓存时间


1、对应要设置的文件路径,设置时间365天

<?xml version="1.0" encoding="UTF-8"?>

<configuration>
    <location path="reset.css">
        <system.webServer>
            <staticContent>
                <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="365.00:00:00" />
            </staticContent>
        </system.webServer>
    </location>
</configuration>


2、缓存某个文件夹下的所有内容

把这个内容放入到web.config里面,然后把这个web.config放至要缓存的文件夹下

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <staticContent>
            <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="365.00:00:00" />
        </staticContent>
    </system.webServer>
</configuration>

3、缓存到哪一天
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <staticContent>
            <clientCache cacheControlMode="UseExpires" httpExpires="Sat, 31 May 2014 07:00:00 GMT" />
        </staticContent>
    </system.webServer>
</configuration>


4、哪个文件缓存对哪天

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <location path="Style.css">
        <system.webServer>
            <staticContent>
                <clientCache cacheControlMode="UseExpires" httpExpires="Sat, 31 May 2014 04:00:00 GMT" />
            </staticContent>
            <httpProtocol allowKeepAlive="false" />
        </system.webServer>
    </location>
</configuration>

5、哪个文件缓存对哪天(日期的格式不一样)
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <location path="Style.css">
        <system.webServer>
            <staticContent>
                <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="2314.19:00:00" />
            </staticContent>
        </system.webServer>
    </location>
</configuration>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值