문제

나는 .js 및 .css 파일을 결합하여 "squishit"를 사용하고 있습니다. 문제는 다른 모든 리소스가 200 (캐시에서) 200 인 경우 304 (변경되지 않음)가 생성 된 번들이 생성된다는 것입니다.파일을 정규 방식으로두면 원하는 200 결과를 얻습니다. 내 코드의 예 :

@MvcHtmlString.Create(@Bundle.JavaScript().Add("~/Scripts/Libs/jquery.cookie.js").Add("~/Scripts/Libs/jquery.dynatree.min.js").Add("~/Scripts/Libs/jquery.json-2.3.min.js").Add("~/Scripts/Libs/jsrender.js").Add("~/Scripts/Libs/jstorage.min.js").Add("~/Scripts/Common/utils.js").Add("~/Scripts/DataServices/AccountDataServices.js").Add("~/Scripts/AccountSelection.js").WithMinifier<SquishIt.Framework.Minifiers.JavaScript.MsMinifier>().Render("~/Scripts/AccSelectionscriptBandle_#.js"))
.

결과 :

여기에 이미지 설명

편집 : "debug= false"를 사용하고 있습니다. 다른 모든 리소스는 200 (캐시에서) 입니다.

도움이 되었습니까?

해결책

나는 당신이 올바른 추적에 있다고 생각하지만 한 단계 더 많은 단계를 더 많이 추가해야합니다. 클라이언트 캐나지 설정에 하나의 옵션을 추가해야합니다 (CacheControlCustom="revalidate") :

    <staticContent>
      <!-- A clients cache will expire 90 days after it is loaded -->
      <!-- each static item is revalidated against the server to see if the LastModifiedDate is different than the If-Modified-Since date-->
      <!-- http://msdn.microsoft.com/en-us/library/ms689443.aspx -->
      <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="90.00:00:00" cacheControlCustom="must-revalidate"/>
    </staticContent>
.

CacheControlCustom은 특정 정적 파일의 LastModifiedDate 및 if-modified-를 비교하기 위해 서버에 대한 검사를 강화합니다.CacheControlMaxage를 설정하면 서버에서 파일을 수정하면 클라이언트가 파일을 다시 가져 오지 않을 수 있습니다.귀하가 갖고있는 설정 (500 일)은 클라이언트의 컴퓨터에 500 일 동안 파일을 끌어 올릴 수 있습니다.그것이 당신의 의도라면, 위대합니다.(또한, 패키지 내의 JS / CSS 파일을 변경하면 다른 해시 이름이 생성되므로 다른 캐싱 동작이 마스크됩니다.)

주석 내의 URL은 MSDN에서 조금 더 설명 할 수 있습니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top