Returns a resource with a fixed Last-Modified date
GETHEAD
https://api.testingapis.com/api/cache/last-modifiedReads If-Modified-Since: a date on or after Wed, 01 Jan 2025 00:00:00 GMT gives a 304. Invalid dates are ignored. Also answers HEAD.
Parameters 1
| Name | Type | Description |
|---|---|---|
If-Modified-Since | header · string | HTTP date; returns 304 when the resource hasn't changed since. |
Responses
- 200
- The resource, with a Last-Modified header.
- 304
- Not modified since the given date.
Example
Request
curl -X GET "https://api.testingapis.com/api/cache/last-modified"Response200 OK
Last-Modified: Wed, 01 Jan 2025 00:00:00 GMT
Cache-Control: no-cache
{
"title": "Unchanged since New Year 2025",
"lastModified": "Wed, 01 Jan 2025 00:00:00 GMT",
"hint": "Send If-Modified-Since with this date (or later) to get 304 Not Modified."
}Code examples
JavaScript (fetch)
const response = await fetch("https://api.testingapis.com/api/cache/last-modified");
console.log(response.status, await response.text());Python (requests)
import requests
response = requests.request(
"GET",
"https://api.testingapis.com/api/cache/last-modified",
allow_redirects=False,
)
print(response.status_code, response.text)Java (HttpClient)
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newBuilder()
.followRedirects(HttpClient.Redirect.NEVER)
.build();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.testingapis.com/api/cache/last-modified"))
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode() + " " + response.body());
}
}