Skip to content

Support if-modified-since headers for API requests #18484

@sbrinkhorst

Description

@sbrinkhorst

Describe the bug
The API headers say the if-modified-since header is supported:
access-control-allow-headers: Content-Type, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since

In practice I don't see this for both the index and json API's, for both of them I get a 200 for libraries that are unlikely to have been changed since the provided timestamp.

Expected behavior

If the data has not been modified, I expect to get a 304 response.

Example from another API:

curl --head -H "If-Modified-Since: Mon, 04 Aug 2025 14:17:44 GMT" https://index.crates.io/ba/se/base64

To Reproduce
Example for beautifulsoup4, which was last changed in April.

curl --head -v -H "Accept: application/vnd.pypi.simple.v1+json" -H "If-Modified-Since: Mon, 04 Aug 2025 14:17:44 GMT" https://pypi.org/simple/beautifulsoup4/
curl --head -v -H "Accept: application/json" -H "If-Modified-Since: Mon, 04 Aug 2025 14:17:44 GMT" https://pypi.org/pypi/beautifulsoup4/json

My Platform
I'm using curl 8.7.1 on my mac (Sequoia 15.5)

curl 8.7.1 (x86_64-apple-darwin24.0) libcurl/8.7.1 (SecureTransport) LibreSSL/3.3.6 zlib/1.2.12 nghttp2/1.64.0
Release-Date: 2024-03-27
Protocols: dict file ftp ftps gopher gophers http https imap imaps ipfs ipns ldap ldaps mqtt pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: alt-svc AsynchDNS GSS-API HSTS HTTP2 HTTPS-proxy IPv6 Kerberos Largefile libz MultiSSL NTLM SPNEGO SSL threadsafe UnixSockets

Additional context
I noticed that the responses from the API are also lacking the last-modified header, maybe that is related.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions