HTTP 304 Not Modified


The HTTP 304 Not Modified status code is used in conditional GET requests to indicate that the resource has not been modified since the last request. This status is used for caching purposes to reduce bandwidth and processing.


The HTTP 304 response is primarily used to inform the client that the cached version of the requested resource is still valid and can be used, eliminating the need to transfer the same data again.


Client Behavior:

  1. Send Conditional Request: The client sends a conditional GET request typically including If-Modified-Since or If-None-Match headers.
  2. Receive Response: The client receives the HTTP 304 status code if the resource has not been modified.

Server Behavior:

  1. Evaluate Request Headers: The server checks the request headers against the current state of the resource.
  2. Send Response: If the resource has not changed, the server sends a 304 Not Modified response without a message body.


  • Resource Caching: To indicate that a cached resource is still valid and does not require re-downloading.
  • Bandwidth Optimization: Reducing bandwidth usage by not sending unchanged resources.

Sequence Diagram

Illustrating the process for an HTTP 304 response:

    participant Client
    participant Server as Web Server

    Note over Client: Client sends a conditional GET request
    Client->>Server: GET /resource HTTP/1.1
    Client->>Server: If-Modified-Since: [Last-Modified Date]
    Note over Server: Server checks resource status
    Server->>Client: HTTP/1.1 304 Not Modified

Curl Request and Response Example

Sending a conditional GET request using Curl to check if a resource has been modified:

curl -i -H "If-Modified-Since: [Last-Modified Date]"
# Expected response: HTTP/1.1 304 Not Modified

PHP cURL Request and Response Example

PHP script using cURL to make a conditional GET request:

$ch = curl_init('');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('If-Modified-Since: [Last-Modified Date]'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
if (curl_getinfo($ch, CURLINFO_HTTP_CODE) == 304) {
    echo "Resource has not been modified.";

Python Request and Response Example

Python script to send a conditional GET request and check for a 304 Not Modified response:

import requests
headers = {'If-Modified-Since': '[Last-Modified Date]'}
response = requests.get('', headers=headers)
if response.status_code == 304:
    print("Resource has not been modified")

Apache Configuration for HTTP 304 Not Modified

Apache server configuration to support conditional GET requests and 304 responses:

<VirtualHost *:80>
    # Ensure proper handling of If-Modified-Since header
    # ...

NGINX Configuration for HTTP 304 Not Modified

Setting up NGINX to handle 304 Not Modified responses for conditional GET requests:

server {
    listen 80;
    location /resource {
        # Configurations for handling If-Modified-Since header
        # ...

HTTP 303 See Other HTTP 305 Use Proxy


Free Weekly


Join my weekly newsletter for the latest in tech! You'll get neat coding tricks, trend updates, career advice, SaaS reviews, crypto, bitcoin, and financial tips. All straight to your inbox, designed to keep you ahead.