HTTP 410 Gone

Overview

The HTTP 410 Gone status code indicates that access to the target resource is no longer available at the server, and this condition is likely to be permanent. It is similar to 404 Not Found, but the 410 status code indicates a more permanent state of resource unavailability.

Purpose

The HTTP 410 response is used to inform the client that the resource is no longer available and that the server does not expect this to change. It’s a signal that the resource has been intentionally removed.

Usage

Client Behavior:

  1. Send Request: The client sends an HTTP request to access a specific resource.
  2. Receive Response: The client receives the HTTP 410 status code, indicating that the resource is permanently gone.

Server Behavior:

  1. Resource Removal: The server identifies that a previously available resource is now permanently removed.
  2. Send Response: The server sends a 410 Gone response to indicate this permanent condition.

Scenarios

  • Permanently Deleted Resources: When a resource has been permanently deleted or removed.
  • Historical Linking: Useful for indicating to clients and search engines that a resource should be de-indexed.

Sequence Diagram

Illustrating the process for an HTTP 410 response:

sequenceDiagram
    participant Client
    participant Server as Web Server

    Note over Client: Client requests a removed resource
    Client->>Server: GET /removed-page HTTP/1.1
    Note over Server: Server identifies resource as permanently removed
    Server->>Client: HTTP/1.1 410 Gone

Curl Request and Response Example

Requesting a removed resource using Curl:

curl -i http://example.com/removed-page
# Expected response: HTTP/1.1 410 Gone

PHP cURL Request and Response Example

PHP script using cURL to handle a 410 Gone response:

<?php
$ch = curl_init('http://example.com/removed-page');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
if (curl_getinfo($ch, CURLINFO_HTTP_CODE) == 410) {
    echo "The requested resource is no longer available.";
}
curl_close($ch);
?>

Python Request and Response Example

Python script to send a GET request to a removed resource and handle a 410 Gone response:

import requests
response = requests.get('http://example.com/removed-page')
if response.status_code == 410:
    print("The requested resource is no longer available")

Apache Configuration for HTTP 410 Gone

Configuring Apache to indicate a permanently removed resource:

<VirtualHost *:80>
    ServerName example.com
    <Location "/removed-page">
        Redirect gone /removed-page
    </Location>
</VirtualHost>

NGINX Configuration for HTTP 410 Gone

Setting up NGINX to respond with a 410 Gone for a removed resource:

server {
    listen 80;
    server_name example.com;
    location /removed-page {
        return 410;
    }
}

HTTP 409 Conflict HTTP 411 Length Required


 

Free Weekly

Newsletter

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.