相关疑难解决方法(0)

如何在IIS7中为每个文件夹和扩展配置静态内容缓存?

我想在IIS7中为我的ASP.NET网站中的静态内容缓存设置规则.

我已经看过这些文章,详细介绍了如何使用以下<clientCache />元素web.config:

客户端缓存<clientCache>(IIS.NET)
将过期或缓存控制标头添加到IIS中的静态内容(堆栈溢出)

但是,此设置似乎全局适用于所有静态内容.有没有办法只为某些目录或扩展这样做?

例如,我可能有两个需要单独缓存设置的目录:

/static/images
/content/pdfs

是否有可能建立规则发送缓存头(max-age,expires基于扩展和文件夹路径等)?

请注意,我必须能够这样做,web.config因为我无法访问IIS控制台.

iis iis-7 caching web-config http-headers

140
推荐指数
2
解决办法
11万
查看次数

利用IIS中的浏览器缓存(google pagespeed issue)

关于利用浏览器缓存有几个问题,但我没有找到任何有助于在ASP.NET应用程序中执行此操作的内容.谷歌的Pagespeed告诉这是性能最大的问题.到目前为止,我在我的web.config中这样做了:

<system.webServer>
  <staticContent>
    <!--<clientCache cacheControlMode="UseExpires"
            httpExpires="Fri, 24 Jan 2014 03:14:07 GMT" /> -->
    <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="7.24:00:00" />
  </staticContent>
</system.webServer>
Run Code Online (Sandbox Code Playgroud)

评论代码有效.我可以将expire header设置为将来某个特定时间,但我无法设置cacheControlMaxAge从现在开始静态内容的缓存天数.这是行不通的.我的问题是:

我怎样才能做到这一点?我知道有可能只为特定的文件夹设置缓存,这是一个很好的解决方案,但它也不起作用.应用程序托管在Windows Server 2012上,在IIS8上,应用程序池设置为经典.

在web配置中设置此代码后,我的页面速度为72(之前为71).没有缓存50个文件.(现在49)我想知道为什么,我只是意识到一个文件实际上是缓存的(svg文件).不幸的是png和jpg文件没有.这是我的web.config

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

<configuration>
  <configSections>
    <section name="exceptionManagement" type="Microsoft.ApplicationBlocks.ExceptionManagement.ExceptionManagerSectionHandler,Microsoft.ApplicationBlocks.ExceptionManagement" />
    <section name="jsonSerialization"     type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions,   Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E34" requirePermission="false" allowDefinition="Everywhere" />
    <sectionGroup name="elmah">
      <section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler, Elmah"    />
      <section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah"    />
      <section name="errorMail" requirePermission="false" type="Elmah.ErrorMailSectionHandler, Elmah" />
      <section name="errorFilter" requirePermission="false" type="Elmah.ErrorFilterSectionHandler, Elmah" />
    </sectionGroup>
  </configSections>

  <exceptionManagement mode="off">
    <publisher …
Run Code Online (Sandbox Code Playgroud)

c# asp.net iis caching httphandler

50
推荐指数
3
解决办法
5万
查看次数

如何将站点范围的无缓存标头添加到MVC 3应用程序

我构建了一个MVC3应用程序,应用程序有很多页面,现在因为安全问题我需要在http标头中添加无缓存设置,是否有更简单的方法可以做到这一点?如果我们可以修改一个地方然后它将适用于整个应用程序,它将是完美的.

你能帮助我吗?

c# asp.net-mvc asp.net-mvc-3

23
推荐指数
2
解决办法
2万
查看次数

文件打开而不是在href链接中的Internet Explorer中下载

<a href="path/to/file/filename.xxx" download="filename.xxx">filename</a>'
Run Code Online (Sandbox Code Playgroud)

当我点击链接时,应该下载我的filename.xxx.

它在chrome中完美运行.但在Internet Explorer中,它会打开文件而不是下载.可能是什么问题呢?是否有任何属性需要添加才能使其工作.

此外,我还需要一个适用于所有浏览器的文件下载示例.

html internet-explorer download

23
推荐指数
2
解决办法
10万
查看次数