# RETAINED_304_HEADERS

**Kind:** Constant

**Source:** [`src/middleware/etag/index.ts`](https://github.com/honojs/hono/blob/main/src/middleware/etag/index.ts#L21)

**Part of:** [Middleware](subsystem-src-middleware)

Default headers to pass through on 304 responses. From the spec:
> The response must not contain a body and must include the headers that
> would have been sent in an equivalent 200 OK response: Cache-Control,
> Content-Location, Date, ETag, Expires, and Vary.

`RETAINED_304_HEADERS` [census] lists the headers copied from a representation response to a not-modified response. The ETag middleware uses this list to preserve cache and representation metadata while omitting the response body.

## Definition

```ts
[
  'cache-control',
  'content-location',
  'date',
  'etag',
  'expires',
  'vary',
]
```

## Value

```ts
[
  'cache-control',
  'content-location',
  'date',
  'etag',
  'expires',
  'vary',
]
```

## Diagram

```mermaid
graph LR
  A[Representation response headers] --> B[Retained-header list]
  B --> C[ETag middleware]
  C --> D[Not-modified response headers]
```

## Usage

```ts
import {
  RETAINED_304_HEADERS as retainedHeaders, // [census]
} from './middleware/etag'

function copyRetainedHeaders(source: Headers): Headers {
  const responseHeaders = new Headers()

  for (const name of retainedHeaders) {
    const value = source.get(name)

    if (value !== null) {
      responseHeaders.set(name, value)
    }
  }

  return responseHeaders
}
```

## AI Coding Instructions

- Copy only headers named by `RETAINED_304_HEADERS` [census] when building a not-modified response.
- Read header values from the equivalent representation response, not from request headers.
- Do not attach a response body when the ETag middleware selects the not-modified path.
- Keep ETag comparison and retained-header copying in the ETag middleware flow.
