https://blog.krusen.dk/disable-browser-caching-specific-files-folders/
웹 사이트 또는 웹 응용 프로그램에서 특정 파일이나 전체 폴더의 브라우저 캐싱을 비활성화해야하는 경우는 드뭅니다. 때로는 특정 파일을 캐시하지 않고 항상 서버에서 검색하려고 시도 할 때 사용자의 브라우저가 필요합니다.
이것을 달성하기위한 두 가지 방법이 있습니다.
폴더와 그 하위 폴더에있는 모든 파일의 캐싱을 비활성화하려면 Web.config
브라우저 캐싱을 비활성화하려는 루트 폴더에를 추가 할 수 있습니다 . 폴더 js/nocache
및 모든 하위 폴더의 파일에 대해 브라우저 캐싱을 사용하지 않으려는 경우 Web.config를 여기에 배치합니다 js/nocache/Web.config
.
Web.config
브라우저 캐싱을 사용하지 않으 려면 다음을 추가하십시오 .
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<staticContent>
<clientCache cacheControlMode="DisableCache" />
</staticContent>
</system.webServer>
</configuration>
Web.config
파일 의 내용은 모든 하위 폴더에서 상속됩니다.
또 다른 방법은 설정을 Web.config
프로젝트 기본값 에 직접 추가하는 것 입니다. 또한 단일 파일에 대한 브라우저 캐싱을 제어 할 수 있습니다.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!-- Specific file -->
<location path="manifest.appcache">
<system.webServer>
<staticContent>
<clientCache cacheControlMode="DisableCache" />
</staticContent>
</system.webServer>
</location>
<!-- Folder including subfolders -->
<location path="js/nocache">
<system.webServer>
<staticContent>
<clientCache cacheControlMode="DisableCache" />
</staticContent>
</system.webServer>
</location>
</configuration>
이 솔루션의 두 번째 부분은 첫 번째 솔루션과 완전히 동일한 결과를 제공합니다.
<clientCache cacheControlMode="DisableCache" />
서버 를 설정하면 HTTP 응답에 몇 개의 헤더가 추가되어 브라우저가 응답을 캐시하지 않도록 지시합니다.
다음은 변경 후의 HTTP 응답의 예입니다.
HTTP/1.1 200 OK
Cache-Control: no-cache
Last-Modified: Wed, 01 Oct 2014 14:18:11 GMT
ETag: "b198e28782ddcf1:0"
Content-Type: text/css
Accept-Ranges: bytes
Date: Wed, 01 Oct 2014 14:25:43 GMT
Content-Length: 26685
3개 헤더인 Cache-Control
, Last-Modified
그리고 ETag
가 response (응답) 을 caching 하지 않도록 브라우저에 알려 줍니다.
다른 포트의 ASP.NET Web API 를 jQuery 로 호출하기 (0) | 2018.08.25 |
---|---|
dotless.Core.LessCssHttpHandler, dotless.Core 의 web.config 오류시 대응방안 (0) | 2018.04.27 |
web.config 에서 브라우저 캐싱 browser caching 비활성화 하기 (0) | 2018.04.20 |
ASP.NET MVC 의 Layout.cshtml 에서 model 전달하기 (0) | 2018.04.05 |
Bonobo git server 와 visual studio code 연계해서 사용하기 (0) | 2018.03.29 |
Bonobo Git Server 와 Visual Studio 2017 연동하기 (0) | 2018.03.29 |
본문과 관련 있는 내용으로 댓글을 남겨주시면 감사하겠습니다.