# DateCache

<a id="datecache"></a>

# DateCache

```cpp
#include <icy/http/server.h>

struct DateCache
```

[Defined in src/http/include/icy/http/server.h:229](https://github.com/auscaster/icey/blob/main/src/http/include/icy/http/server.h#L229)

Caches the formatted Date header, updated once per second. Avoids per-request time formatting and string allocation.

## Public Attributes

| Return | Name | Description |
|--------|------|-------------|
| `char` | [`buf`](#buf)  |  |
| `size_t` | [`len`](#len)  |  |
| `std::time_t` | [`lastSecond`](#lastsecond)  |  |

---

<a id="buf"></a>

### buf

```cpp
char buf[64]
```

[Defined in src/http/include/icy/http/server.h:231](https://github.com/auscaster/icey/blob/main/src/http/include/icy/http/server.h#L231)

---

<a id="len"></a>

### len

```cpp
size_t len = 0
```

[Defined in src/http/include/icy/http/server.h:232](https://github.com/auscaster/icey/blob/main/src/http/include/icy/http/server.h#L232)

---

<a id="lastsecond"></a>

### lastSecond

```cpp
std::time_t lastSecond = 0
```

[Defined in src/http/include/icy/http/server.h:233](https://github.com/auscaster/icey/blob/main/src/http/include/icy/http/server.h#L233)

## Public Methods

| Return | Name | Description |
|--------|------|-------------|
| `void` | [`update`](#update-4) `inline` | Refreshes the cached Date header string if the current second has changed. No-op if called multiple times within the same second. |
| `const char *` | [`data`](#data-7) `const` `inline` | Returns a pointer to the formatted "Date: ...\r\n" header string. |
| `size_t` | [`size`](#size-9) `const` `inline` | Returns the byte length of the formatted Date header string. |

---

<a id="update-4"></a>

### update

`inline`

```cpp
inline void update()
```

[Defined in src/http/include/icy/http/server.h:237](https://github.com/auscaster/icey/blob/main/src/http/include/icy/http/server.h#L237)

Refreshes the cached Date header string if the current second has changed. No-op if called multiple times within the same second.

---

<a id="data-7"></a>

### data

`const` `inline`

```cpp
inline const char * data() const
```

[Defined in src/http/include/icy/http/server.h:254](https://github.com/auscaster/icey/blob/main/src/http/include/icy/http/server.h#L254)

Returns a pointer to the formatted "Date: ...\r\n" header string.

---

<a id="size-9"></a>

### size

`const` `inline`

```cpp
inline size_t size() const
```

[Defined in src/http/include/icy/http/server.h:257](https://github.com/auscaster/icey/blob/main/src/http/include/icy/http/server.h#L257)

Returns the byte length of the formatted Date header string.
