【问题标题】:IIS bundles/less cache issueIIS 捆绑包/更少的缓存问题
【发布时间】:2015-09-21 00:31:25
【问题描述】:

我有一个 ASP.NET MVC 5 项目,它使用 dotless 来解析/编译 .less 文件和标准捆绑器来缩小/捆绑 js 文件。

问题是,在生产服务器上,缓存控制标头设置为max-age=0, no-cache, no-store,而在本地 IIS express 上它设置为public,并在一年内到期。

无点配置:<dotless minifyCss="true" cache="true" web="true" handleWebCompression="false" />

捆绑配置 - 仅包含和 BundleTable.EnableOptimizations = true;

一些可能有帮助的网络配置部分:

<staticContent>
  <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="7.00:00:00" />
</staticContent>
...
<modules runAllManagedModulesForAllRequests="true">
  <add name="Prerender" type="Prerender.io.PrerenderModule, Prerender.io, Version=1.0.0.2, Culture=neutral, PublicKeyToken=null"/>
  <add name="Spring" type="Spring.Context.Support.WebSupportModule, Spring.Web" />
  <add name="OpenSessionInView" type="Spring.Data.NHibernate.Support.OpenSessionInViewModule, Spring.Data.NHibernate32" />
</modules>
...
<handlers>
  <remove name="OPTIONSVerbHandler" />
  <remove name="TRACEVerbHandler" />
  <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
  <add name="dotless" path="*.less" verb="GET" type="dotless.Core.LessCssHttpHandler,dotless.Core" resourceType="File" preCondition="" />
</handlers>

我尝试将 mime 映射添加到 staticContent 部分。还考虑在 iis 中添加请求标头,但它仅适用于文件/文件夹,因此它可能不会提供捆绑服务。

我在配置中遗漏了什么?我感谢任何解决此问题的想法。

【问题讨论】:

    标签: asp.net asp.net-mvc caching iis cache-control


    【解决方案1】:

    检查你的 web.config 中是否有这些东西:

    <configuration>
        <system.web>
            <compilation debug="false"/>
    

    【讨论】:

    • 本地是 &lt;compilation debug="true" targetFramework="4.5.1"&gt; ,在生产部署后 - &lt;compilation targetFramework="4.5.1"&gt; 。我尝试了 truefalse 值 - 但没有帮助。
    猜你喜欢
    • 2013-01-21
    • 1970-01-01
    • 2019-06-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-20
    相关资源
    最近更新 更多