---
title: "HTTP Cache Control Directives (Types)"  
description: "HTTP Cache Control Directives (Types)"  
author: "ICSM Computer"  
published: 2025-08-03  
updated: 2025-08-03  
canonical: https://www.mindstick.com/interview/34345/http-cache-control-directives-types  
category: "cache"  
tags: ["cache"]  
reading_time: 4 minutes  

---

# HTTP Cache Control Directives (Types)

## HTTP [Cache](https://www.mindstick.com/interview/34344/what-is-cache) Control Directives (Types)

| **Directive** | **Description** |
| --- | --- |
| `public` | Can be cached by **any cache** (browser, CDN, proxy). Safe for shared caching. |
| `private` | Can be cached **only by the browser**. Not cached by shared caches like proxies. |
| `no-cache` | Cached copy **must be revalidated** with the server before being used. |
| `no-store` | **Do not cache** at all — not even in memory. Best for sensitive data (e.g., login). |
| `max-age=n` | Specifies how long (in seconds) the response is considered **fresh**. |
| `s-maxage=n` | Like `max-age`, but specific to **shared caches** (e.g., CDNs). |
| `must-revalidate` | The cache **must check with the server** before using expired content. |
| `proxy-revalidate` | Like `must-revalidate`, but for shared caches. |
| `immutable` | Indicates the response **won’t change**, so no need to revalidate. |
| `stale-while-revalidate` | Allows serving stale content **while** revalidating in the background. |

## Examples

### 1. Public

```plaintext
Cache-Control: public, max-age=86400
```

- Can be stored by browser **and** intermediate caches (CDNs, proxies).
- Good for static files like images, CSS, JS.

### 2. Private

```plaintext
Cache-Control: private, max-age=600
```

- Only the **end user's browser** can cache this.
- Useful for **personalized content** (e.g., user dashboards).

### 3. No-Cache

```plaintext
Cache-Control: no-cache
```

- Cached, but **must check with server** before using.
- Safer when data might change frequently.

### 4. No-Store

```plaintext
Cache-Control: no-store
```

- **No caching allowed**. Not stored in memory, disk, or anywhere.
- Used for sensitive data (e.g., banking, login pages).

## Summary Table

| **Directive** | **Can Cache?** | **Who Can Cache?** | **Needs Validation?** | **Use Case** |
| --- | --- | --- | --- | --- |
| `public` | Yes | Anyone (browser, CDN) | if fresh | Static resources |
| `private` | Yes | Browser only | if fresh | User-specific pages |
| `no-cache` | Yes | Browser or CDN | always | Dynamic but not sensitive |
| `no-store` | NO | Nobody | always | Passwords, banking info |
| `max-age=3600` | Yes | Depends on public/private | for set duration | Control how long it's fresh |

## Answers

### Answer by ICSM Computer

## HTTP [Cache](https://www.mindstick.com/interview/34344/what-is-cache) Control Directives (Types)

| **Directive** | **Description** |
| --- | --- |
| `public` | Can be cached by **any cache** (browser, CDN, proxy). Safe for shared caching. |
| `private` | Can be cached **only by the browser**. Not cached by shared caches like proxies. |
| `no-cache` | Cached copy **must be revalidated** with the server before being used. |
| `no-store` | **Do not cache** at all — not even in memory. Best for sensitive data (e.g., login). |
| `max-age=n` | Specifies how long (in seconds) the response is considered **fresh**. |
| `s-maxage=n` | Like `max-age`, but specific to **shared caches** (e.g., CDNs). |
| `must-revalidate` | The cache **must check with the server** before using expired content. |
| `proxy-revalidate` | Like `must-revalidate`, but for shared caches. |
| `immutable` | Indicates the response **won’t change**, so no need to revalidate. |
| `stale-while-revalidate` | Allows serving stale content **while** revalidating in the background. |

## Examples

### 1. Public

```plaintext
Cache-Control: public, max-age=86400
```

- Can be stored by browser **and** intermediate caches (CDNs, proxies).
- Good for static files like images, CSS, JS.

### 2. Private

```plaintext
Cache-Control: private, max-age=600
```

- Only the **end user's browser** can cache this.
- Useful for **personalized content** (e.g., user dashboards).

### 3. No-Cache

```plaintext
Cache-Control: no-cache
```

- Cached, but **must check with server** before using.
- Safer when data might change frequently.

### 4. No-Store

```plaintext
Cache-Control: no-store
```

- **No caching allowed**. Not stored in memory, disk, or anywhere.
- Used for sensitive data (e.g., banking, login pages).

## Summary Table

| **Directive** | **Can Cache?** | **Who Can Cache?** | **Needs Validation?** | **Use Case** |
| --- | --- | --- | --- | --- |
| `public` | Yes | Anyone (browser, CDN) | if fresh | Static resources |
| `private` | Yes | Browser only | if fresh | User-specific pages |
| `no-cache` | Yes | Browser or CDN | always | Dynamic but not sensitive |
| `no-store` | NO | Nobody | always | Passwords, banking info |
| `max-age=3600` | Yes | Depends on public/private | for set duration | Control how long it's fresh |


---

Original Source: https://www.mindstick.com/interview/34345/http-cache-control-directives-types

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
