What Does the aria2 –conditional-get Flag Do?

The --conditional-get flag in aria2 is a powerful feature that optimizes file downloads by checking if a remote file has changed before downloading it again. When enabled, aria2 leverages HTTP headers to verify the file’s modification status on the server. If the local file is already up to date, the utility skips the download, saving both time and network bandwidth. This makes it an essential tool for automating scripts, mirroring repositories, or regularly downloading frequently updated files.

How Conditional GET Works in aria2

When you use the --conditional-get flag (or set it to true), aria2 changes how it initiates a download request. Instead of blindly downloading the file, it looks for an existing local file or an associated .aria2 control file to gather timestamp and validation data.

It then utilizes specific HTTP mechanism headers to communicate with the server:

The Server’s Response

Depending on whether the remote file has been updated, the server will respond in one of two ways:

  1. 304 Not Modified: If the file on the server matches the local file’s timestamp or ETag, the server returns a 304 Not Modified status code. aria2 recognizes this, immediately terminates the transfer, and leaves your local file untouched.
  2. 200 OK: If the file has changed on the server, the server responds with a standard 200 OK status and sends the new, updated file. aria2 will then overwrite the old local file with the fresh version.

Key Benefits of Using This Flag

Implementing --conditional-get in your download workflows provides several distinct advantages:

Example Usage

To use this feature in the command line, simply append the flag to your standard aria2 command:

aria2c --conditional-get=true https://example.com/file.zip

Note: For this flag to work effectively, the remote web server must support conditional HTTP requests (by properly issuing ETags or Last-Modified headers), and the file must be downloaded to a directory where the previous version or its metadata can be tracked.