1

Asp.net Web サイトを作成して、静的ファイルをブラウザー クライアントにキャッシュしようとしています。

これらの手順に従いました

私のウェブ設定:

<configuration>
  <!-- elements removed for readability -->

  <location path="content">
    <system.webServer>
      <staticContent>
        <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="100:00:00" />
      </staticContent>
    </system.webServer>
  </location>
</configuration>

ただし、Contentフォルダーから js ファイルを要求しても、ファイルはキャッシュされません。

ここに画像の説明を入力

私は何を間違っていますか?私は本当にこの問題を解決する必要があります。

4

1 に答える 1

0

web.config から構成を削除System.Web.StaticFileHandlerすると問題は解決しましたが、これが問題を解決する正しい方法であるかどうかはわかりません。

<system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <handlers>
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
      <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />

      <!--  Removing these rules makes the cache to work.
            With them, it doesn't work

      <add verb="GET" path="*.js" name="Static for js" type="System.Web.StaticFileHandler" />
      <add verb="GET" path="*.css" name="Static for css" type="System.Web.StaticFileHandler" />
      <add verb="GET" path="*.png" name="Static for png" type="System.Web.StaticFileHandler" />
      <add verb="GET" path="*.jpg" name="Static for jpg" type="System.Web.StaticFileHandler" />
      -->
    </handlers>

    <staticContent>
      <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="100:00:00" />
    </staticContent>
  </system.webServer>
于 2013-09-19T09:25:07.530 に答える