aboutsummaryrefslogtreecommitdiff
path: root/files/ko/web/http/headers/cache-control/index.html
blob: 28225982b0d655efc593fa86d96e486d5c366ced (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
---
title: Cache-Control
slug: Web/HTTP/Headers/Cache-Control
translation_of: Web/HTTP/Headers/Cache-Control
---
<div>{{HTTPSidebar}}</div>

<p><strong><code>Cache-Control</code></strong> 일반 헤더 필드는 요청과 응답 내의 캐싱 메커니즘을 위한 디렉티브를 정하기 위해 사용됩니다. 캐싱 디렉티브는 단방향성이며, 이는 요청 내에 주어진 디렉티브가 응답 내에 주어진 디렉티브와 동일하다는 것을 뜻하지는 않는다는 것을 의미합니다.</p>

<table class="properties">
 <tbody>
  <tr>
   <th scope="row">Header type</th>
   <td>{{Glossary("General header")}}</td>
  </tr>
  <tr>
   <th scope="row">{{Glossary("Forbidden header name")}}</th>
   <td>no</td>
  </tr>
  <tr>
   <th scope="row">{{Glossary("Simple response header", "CORS-safelisted response-header")}}</th>
   <td>yes</td>
  </tr>
 </tbody>
</table>

<h2 id="문법">문법</h2>

<p>디렉티브는 대소문자를 구분하지 않으며 토큰과 따옴표로 둘러쌓인 문자열 문법 모두를 사용할 수 있는 부가적인 인자를 가집니다. 다중 디렉티브는 쉼표로 구분됩니다.</p>

<h3 id="캐시_요청_디렉티브">캐시 요청 디렉티브</h3>

<p>HTTP 요청 내에서 클라이언트에 의해 사용될 수 있는 표준 <code>Cache-Control</code> 디렉티브.</p>

<pre class="syntaxbox">Cache-Control: max-age=&lt;seconds&gt;
Cache-Control: max-stale[=&lt;seconds&gt;]
Cache-Control: min-fresh=&lt;seconds&gt;
Cache-control: no-cache
Cache-control: no-store
Cache-control: no-transform
Cache-control: only-if-cached
</pre>

<h3 id="캐시_응답_디렉티브">캐시 응답 디렉티브</h3>

<p>HTTP 응답 내에서 서버에 의해 사용될 수 있는 표준 <code>Cache-Control</code> 디렉티브.</p>

<pre class="syntaxbox">Cache-control: must-revalidate
Cache-control: no-cache
Cache-control: no-store
Cache-control: no-transform
Cache-control: public
Cache-control: private
Cache-control: proxy-revalidate
Cache-Control: max-age=&lt;seconds&gt;
Cache-control: s-maxage=&lt;seconds&gt;
</pre>

<h3 id="확장_Cache-Control_디렉티브">확장 <code>Cache-Control</code> 디렉티브</h3>

<p>확장 <code>Cache-Control</code> 디렉티브는 핵심 HTTP 캐싱 표준 문서에 속하지 않습니다. 지원 여부는 <a href="#Browser_compatibility">호환성 테이블</a>을 확인하시기 바랍니다.</p>

<pre class="syntaxbox">Cache-control: immutable
Cache-control: stale-while-revalidate=&lt;seconds&gt;
Cache-control: stale-if-error=&lt;seconds&gt;
</pre>

<h2 id="디렉티브">디렉티브</h2>

<h3 id="캐시_능력">캐시 능력</h3>

<dl>
 <dt><code>public</code></dt>
 <dd>응답이 어떤 캐시에 의해서든 캐시된다는 것을 나타냅니다.</dd>
 <dt><code>private</code></dt>
 <dd>응답이 단일 사용자를 위한 것이며 공유 캐시에 의해 저장되지 않아야 한다는 것을 나타냅니다. 사설 캐시는 응답을 저장할 수도 있습니다.</dd>
 <dt><code>no-cache</code></dt>
 <dd>캐시된 복사본을 사용자에게 보여주기 이전에, 재검증을 위한 요청을 원 서버로 보내도록 강제합니다.</dd>
 <dt><code>only-if-cached</code></dt>
 <dd>새로운 데이터를 내려받지 않음을 나타냅니다. 클라이언트는 캐시된 응답만을 원하며, 더 최신 복사본이 존재하는지를 알아보기 위해 서버에 요청해선 안됩니다.</dd>
</dl>

<h3 id="만료">만료</h3>

<dl>
 <dt><code>max-age=&lt;seconds&gt;</code></dt>
 <dd>리소스가 최신 상태라고 판단할 최대 시간을 지정합니다. <code>Expires</code>에 반해, 이 디렉티브는 요청 시간과 관련이 있습니다.</dd>
 <dt><code>s-maxage=&lt;seconds&gt;</code></dt>
 <dd><code>max-age</code> 혹은 <code>Expires</code> 헤더를 재정의하나, (프록시와 같은) 공유 캐시에만 적용되며 사설 캐시에 의해서는 무시됩니다.</dd>
 <dt><code>max-stale[=&lt;seconds&gt;]</code></dt>
 <dd>클라이언트가 캐시의 만료 시간을 초과한 응답을 받아들일지를 나타냅니다. 부가적으로, 초 단위의 값을 할당할 수 있는데, 이는 응답이 결코 만료되서는 안되는 시간을 나타냅니다.</dd>
 <dt><code>min-fresh=&lt;seconds&gt;</code></dt>
 <dd>클라이언트가 지정된 시간(초단위) 동안 신선한 상태로 유지될 응답을 원한다는 것을 나타냅니다.</dd>
 <dt><code>stale-while-revalidate=&lt;seconds&gt;</code> {{experimental_inline}}</dt>
 <dd>비동기 적으로 백그라운드 에서 새로운 것으로 체크인하는 동안 클라이언트가 최신이 아닌 응답을 받아 들일 것임을 나타냅니다. 초 값은 클라이언트가 최신이 아닌 응답을 받아 들일 시간을 나타냅니다.</dd>
 <dt><code>stale-if-error=&lt;seconds&gt;</code> {{experimental_inline}}</dt>
 <dd>...</dd>
</dl>

<h3 id="재검증과_리로딩">재검증과 리로딩</h3>

<dl>
 <dt><code>must-revalidate</code></dt>
 <dd>캐시는 사용하기 이전에 기존 리소스의 상태를 반드시 확인해야 하며 만료된 리소스는 사용되어서는 안됩니다.</dd>
 <dt><code>proxy-revalidate</code></dt>
 <dd><code>must-revalidate</code>와 동일하지만, (프록시와 같은)공유 캐시에만 적용되며 사설 캐시에 의해서는 무시됩니다.</dd>
 <dt><code>immutable</code></dt>
 <dd>응답 본문이 계속해서 변하지 않을 것이라는 것을 나타냅니다. 응답은, 만료되지 않은 경우라면, 서버 상에서 변경되지 않을 것이고 그러므로 클라이언트는 업데이트 검사를 위해 (<code>If-None-Match</code> 혹은 <code>If-Modified-Since</code>과 같은)그에 대한 조건부의 재검증을 전송해서는 안 됩니다. 이 확장을 감지하지못한 클라이언트는 HTTP 명세에 따라 그것들을 무시해야만 합니다. 파이어폭스에서, <code>immutable</code><code>https://</code> 트랜잭션 상에서만 부여됩니다. 좀 더 많은 정보는 다음의 <a href="http://bitsup.blogspot.de/2016/05/cache-control-immutable.html">블로그 포스트</a>를 참고하시기 바랍니다.</dd>
</dl>

<h3 id="기타">기타</h3>

<dl>
 <dt><code>no-store</code></dt>
 <dd>캐시는 클라이언트 요청 혹은 서버 응답에 관해서 어떤 것도 저장해서는 안됩니다.</dd>
 <dt><code>no-transform</code></dt>
 <dd>응답에 대해 변형이나 변환이 일어나서는 안됩니다. Content-Encoding, Content-Range, Content-Type 헤더는 프록시에 의해서 수정되어서는 안됩니다. 반투명 프록시는, 예를 들어, 캐시 공간을 절약하고 느린 링크 상의 트래픽량을 줄이기 위해 이미지 포맷들을 변환합니다. <code>no-transform</code> 디렉티브는 이를 허용하지 않습니다.</dd>
</dl>

<h2 id="예제">예제</h2>

<h3 id="캐싱_막기">캐싱 막기</h3>

<p>캐싱을 끄기 위해서, 다음의 디렉티브들을 보낼 수 있습니다. 추가로, <code>Expires와</code> <code>Pragma</code> 헤더를 참고하시기 바랍니다.</p>

<pre class="brush: bash">Cache-Control: no-cache, no-store, must-revalidate
</pre>

<h3 id="정적_에셋_캐싱">정적 에셋 캐싱</h3>

<p>변경되지 않을 애플리케이션 내 파일들에 대해, 보통 적극적인 캐싱을 추가할 수 있습니다. 이것은 예를 들자면, 이미지, CSS 파일 그리고 자바스크립트 파일과 같이 애플리케이션에 의해 서브되는 정적 파일들을 포함합니다. 추가로, <code>Expires</code> 헤더를 참고하시기 바랍니다.</p>

<pre class="brush: bash">Cache-Control:public, max-age=31536000</pre>

<h2 id="명세">명세</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">명세</th>
   <th scope="col">제목</th>
  </tr>
  <tr>
   <td>{{RFC("7234")}}</td>
   <td>Hypertext Transfer Protocol (HTTP/1.1): Caching</td>
  </tr>
  <tr>
   <td>{{RFC("5861")}}</td>
   <td>HTTP Cache-Control Extensions for Stale Content</td>
  </tr>
  <tr>
   <td>{{RFC("8246")}}</td>
   <td>HTTP Immutable Responses</td>
  </tr>
 </tbody>
</table>

<h2 id="브라우저_호환성">브라우저 호환성</h2>

<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>

<p>{{Compat("http.headers.Cache-Control")}}</p>

<h2 id="함께_참고할_내용">함께 참고할 내용</h2>

<ul>
 <li><a href="/en-US/docs/Web/HTTP/Caching_FAQ">HTTP Caching FAQ</a></li>
 <li>{{HTTPHeader("Age")}}</li>
 <li>{{HTTPHeader("Expires")}}</li>
 <li>{{HTTPHeader("Pragma")}}</li>
</ul>