ASP.NET 웹 사이트에서 정적 콘텐츠 캐싱에 대한 IIS7의 규칙을 설정하고 싶습니다.
이 기사를 보았습니다.이 <clientCache />요소는 web.config다음 의 요소를 사용하여 수행하는 방법을 자세히 설명합니다 .
클라이언트 캐시
<clientCache>(IIS.NET)
IIS의 정적 콘텐츠에 만료 또는 캐시 제어 헤더 추가 (스택 오버플로)
그러나이 설정은 모든 정적 콘텐츠에 전체적으로 적용되는 것으로 보입니다. 특정 디렉토리 나 확장명에 대해서만이를 수행 할 수있는 방법이 있습니까?
예를 들어 별도의 캐시 설정이 필요한 두 개의 디렉토리가있을 수 있습니다.
/static/images
/content/pdfs
그것은 (캐시 헤더를 보내는 규칙을 설정할 수 있습니다 max-age, expires확장 및 폴더 경로에 따라, 등)?
web.configIIS 콘솔에 액세스 할 수 없기 때문에이 작업을 수행 할 수 있어야합니다 .
답변
루트 중 하나에서 전체 폴더에 대해 특정 캐시 헤더를 설정할 수 있습니다 web.config.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <!-- Note the use of the 'location' tag to specify which
       folder this applies to-->
  <location path="images">
    <system.webServer>
      <staticContent>
        <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="00:00:15" />
      </staticContent>
    </system.webServer>
  </location>
</configuration>
또는 web.config컨텐츠 폴더 의 파일에서이를 지정할 수 있습니다 .
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <staticContent>
      <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="00:00:15" />
    </staticContent>
  </system.webServer>
</configuration>
특정 파일 형식을 대상으로하는 메커니즘이 내장되어 있지 않습니다.
답변
파일 단위로 수행 할 수 있습니다. 경로 속성을 사용하여 파일 이름을 포함하십시오.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <location path="YourFileNameHere.xml">
        <system.webServer>
            <staticContent>
                <clientCache cacheControlMode="DisableCache" />
            </staticContent>
        </system.webServer>
    </location>
</configuration>
답변
나는 같은 문제를 겪었다. 나에게 문제는 이미지에 대한 캐시 제한을 구성하는 방법이었다. 그리고 나는이 사이트를 방문하여 문제를 처리하는 방법에 대한 절차에 대한 통찰력을 얻었습니다. : [ https://varvy.com/pagespeed/cache-control.html]
