IIS7缓存控制 [英] IIS7 Cache-Control

查看:1331
本文介绍了IIS7缓存控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图做一些事情,我认为将是相当简单的。获取IIS 7告诉他们可以缓存我的网站上全部图像进行一定的时间的客户,让我们说24小时。

I'm trying to do something which I thought would be fairly simple. Get IIS 7 to tell clients they can cache all images on my site for a certain amount of time, let's say 24 hours.

我曾尝试在<一个步骤href=\"http://www.galcho.com/Blog/post/2008/02/27/IIS7-How-to-set-cache-control-for-static-content.aspx\">http://www.galcho.com/Blog/post/2008/02/27/IIS7-How-to-set-cache-control-for-static-content.aspx但无济于事。我仍然可以请求将服务器与正在返回304S。

I have tried the step on http://www.galcho.com/Blog/post/2008/02/27/IIS7-How-to-set-cache-control-for-static-content.aspx but to no avail. I still get requests going to the server with 304s being returned.

有没有人有这样做的方法吗?我有一个图形密集型的网站,我的用户正在敲定(所以是我的服务器)每次请求页面的时间。 Wierdly图像似乎有缓存控制私人,最大年龄= 3600显示在Firebug起来,但浏览器仍然要求他们当我preSS F5。

Does anyone have a way of doing this? I have a graphically intensive site and my users are being hammered (so is my server) every time they request a page. Wierdly the images seem to have "Cache-Control private,max-age=3600" showing up in Firebug but the browser is still requesting them when I press F5.

推荐答案

如果您想设置Cache-Control头,没有什么在IIS7 UI要做到这一点,可悲的。

If you want to set the Cache-Control header, there's nothing in the IIS7 UI to do this, sadly.

您可以在文件夹或站点的根目录要设置但是放弃这一web.config中:

You can however drop this web.config in the root of the folder or site where you want to set it:

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

这将通知客户端缓存内容7天该文件夹和所有子文件夹英寸

That will inform the client to cache content for 7 days in that folder and all subfolders.

您还可以通过 Appcmd.exe的编辑IIS7元数据库,喜欢做这样:

You can also do this by editing the IIS7 metabase via appcmd.exe, like so:


\Windows\system32\inetsrv\appcmd.exe 
  set config "Default Web Site/folder" 
  -section:system.webServer/staticContent 
  -clientCache.cacheControlMode:UseMaxAge

\Windows\system32\inetsrv\appcmd.exe 
  set config "Default Web Site/folder" 
  -section:system.webServer/staticContent 
  -clientCache.cacheControlMaxAge:"7.00:00:00"

这篇关于IIS7缓存控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆