[{"data":1,"prerenderedAt":36},["ShallowReactive",2],{"blog:post:en:resume-large-downloads-rotating-proxies":3,"blog:related:en:resume-large-downloads-rotating-proxies":23},{"slug":4,"lang":5,"title":6,"summary":7,"date":8,"tags":9,"tag_slugs":15,"thumbnail_url":16,"translations":17,"body":18,"asset_base":19,"checksum":20,"published_at":21,"content_updated_at":22},"resume-large-downloads-rotating-proxies","en","Resume Large Downloads Through Rotating Proxies","Learn how HTTP Range requests let you resume interrupted downloads through rotating proxies, and why sticky rotation keeps each byte consistent.","2026-11-28",[10,11,12,13,14],"proxy","python","proxy-rotation","http","retry",[10,11,12,13,14],"https://blog-api.ro-proxy.com/api/blog/posts/resume-large-downloads-rotating-proxies/thumbnail.svg?lang=en",[5],"## The problem: a 2 GB download that dies at 1.4 GB\n\nLong transfers through a proxy rarely fail cleanly. The upstream connection drops, the proxy rotates the IP mid-transfer, or the origin throttles you, and your downloader is left holding a truncated file. Restarting from zero throws away the bandwidth and minutes you already spent, and on rate-limited or metered endpoints those repeated full restarts can push you straight into a block.\n\nThe fix is HTTP Range requests. They let a client ask for \"only the bytes I'm missing,\" so an interrupted transfer resumes instead of restarting. Paired with a proxy that holds one IP for the duration, resumable downloads turn from fragile to dependable.\n\n## How Range requests work\n\nA plain GET asks for the whole body and gets `200 OK`. Add a `Range` header and a compliant server replies `206 Partial Content` with just the requested slice, plus a `Content-Range` header describing exactly what it sent:\n\n```\nRange: bytes=1400000000-\n```\n\n```\nHTTP/1.1 206 Partial Content\nContent-Range: bytes 1400000000-2147483647/2147483648\nContent-Length: 747483648\n```\n\nThe client appends that slice to the bytes already on disk. If the server ignores `Range`, it answers `200 OK` with the full body, and you detect that from the status code and simply start over.\n\n### Resume with cURL\n\n`curl` supports this natively. `-C -` reads the size of the local file and sends the matching `Range` for you:\n\n```bash\ncurl -C - -L \\\n  -x http://USERNAME:PASSWORD@GATEWAY_HOST:HTTP_PORT \\\n  -o bigfile.zip \\\n  https://example.com/bigfile.zip\n```\n\nRun the same command again after any failure and it picks up where it left off.\n\n### Resume in Python\n\n`requests` gives the same control. Use `stream=True` so you never hold the whole file in memory, and send `If-Range` with a stored `ETag` so the server only honors the partial request when the file is unchanged:\n\n```python\nimport os\nimport requests\n\nPROXY = \"http://USERNAME:PASSWORD@GATEWAY_HOST:HTTP_PORT\"\nURL = \"https://example.com/bigfile.zip\"\nDEST = \"bigfile.zip\"\n\ndef download_resume(url, dest, proxy, etag=None):\n    proxies = {\"http\": proxy, \"https\": proxy}\n    have = os.path.getsize(dest) if os.path.exists(dest) else 0\n    headers = {}\n    if have:\n        headers[\"Range\"] = f\"bytes={have}-\"\n        if etag:\n            headers[\"If-Range\"] = etag\n    with requests.get(url, headers=headers, proxies=proxies,\n                      stream=True, timeout=30) as r:\n        new_etag = r.headers.get(\"ETag\")\n        if r.status_code == 206:\n            mode = \"ab\"           # append the missing bytes\n        elif r.status_code == 200:\n            mode, have = \"wb\", 0  # server ignored Range; start fresh\n        else:\n            r.raise_for_status()\n        with open(dest, mode) as f:\n            for chunk in r.iter_content(65536):\n                f.write(chunk)\n        return os.path.getsize(dest), new_etag\n```\n\n## Why proxy rotation breaks naive resume\n\nHere is the part most people miss. When a proxy rotates the IP in the middle of a transfer, the resume request can arrive from a different address than the one that served the earlier bytes. Two things go wrong:\n\n- Some origins bind a download to the client IP or a short-lived server-side session. A resume from a new IP returns `200 OK` (a full restart) or `403`, so you never make forward progress.\n- A freshly rotated IP is unproven to the origin and may get throttled or challenged, turning one clean download into an endless loop of failures.\n\nThe answer is to decouple rotation from the transfer itself. Rotate between files, never within one.\n\n### Hold one IP for the whole transfer\n\nUse a sticky rotation mode so the proxy keeps its IP until you rotate it or the IP fails. With RoProxy each proxy connects through a gateway host on an HTTP port and carries its own rotation mode; set it to sticky for the length of a large download:\n\n```\nhttp://USERNAME:PASSWORD@GATEWAY_HOST:HTTP_PORT\n```\n\nNow every chunk, including each resume, comes from the same address, so `206` responses stay consistent. When the file finishes, rotate the IP and move on to the next one.\n\n### Wrap it with retries that resume\n\nBecause every attempt re-reads the file size, a simple retry loop resumes automatically rather than restarting:\n\n```python\nimport time\n\ndef download_with_resume(url, dest, proxy, attempts=5):\n    etag = None\n    for i in range(attempts):\n        try:\n            size, etag = download_resume(url, dest, proxy, etag)\n            return size\n        except requests.RequestException as e:\n            have = os.path.getsize(dest) if os.path.exists(dest) else 0\n            print(f\"Attempt {i+1} failed: {e}. Resuming from {have} bytes.\")\n            time.sleep(2 ** i)  # exponential backoff\n    raise RuntimeError(\"Download failed after retries\")\n```\n\n## Confirm which IP served the bytes\n\nWhen a resume keeps failing, verify the exit IP so you know whether rotation is the culprit. Ask an IP echo service through the very same proxy:\n\n```python\ndef exit_ip(proxy):\n    proxies = {\"http\": proxy, \"https\": proxy}\n    r = requests.get(\"https://api.ipify.org?format=json\",\n                     proxies=proxies, timeout=15)\n    return r.json()[\"ip\"]\n\nprint(exit_ip(PROXY))  # should stay constant while rotation is sticky\n```\n\nIf the address changes between attempts, your rotation mode is not sticky, or the IP failed and was replaced. Either way, you have your diagnosis.\n\n## Edge cases worth handling\n\n- Server ignores `Range`: you get `200`, and the code above resets and restarts cleanly. Log it so you know resume is unavailable for that host.\n- File changed upstream: `If-Range` with the stored `ETag` makes the server return `200` instead of a mismatched `206`, which prevents a corrupt merge of old and new bytes.\n- Missing `Content-Length`: you cannot compute a grand total, but append-based resume still works; track progress by bytes on disk instead.\n- Very large offsets: some proxies handle huge ranges poorly. If a single resume stalls, fetch smaller windows (say 64 MB at a time) and loop until the file is complete.\n\n## Putting it together\n\nResumable downloads are cheap to add and save real bandwidth. Two rules make them work through a proxy: use `Range` (with `If-Range` whenever the origin provides a validator) so you only fetch missing bytes, and keep one IP for the whole transfer so the origin keeps honoring partial content. If your downloads keep snapping back to zero, a sticky proxy from RoProxy holds a single IP across the transfer while you still rotate freely between files.\n","https://blog-api.ro-proxy.com/api/blog/posts/resume-large-downloads-rotating-proxies/assets","355b0c0d9a0a7eb589c3bcfbf2af8b5df44eb9ec4eb58fca472c36dded270850","2026-11-28T01:06:40.848768Z","2026-11-28T01:06:40.850887Z",[24,28,32],{"slug":25,"title":26,"summary":27},"python-proxy-rotation-jitter-backoff","Proxy Rotation with Jitter and Exponential Backoff in Python","Adding jitter and exponential backoff to proxy rotation prevents rate-limit bans. This post covers Python code, RoProxy setup, and exit-IP checks.",{"slug":29,"title":30,"summary":31},"honor-retry-after-headers-scraping","How to Honor Retry-After Headers When Scraping with Proxies","Parse Retry-After seconds and HTTP-date values in Python, keep per-proxy backoff state, and rotate IPs only when the wait is too long.",{"slug":33,"title":34,"summary":35},"proxy-aware-retry-queue-python","Building a Proxy-Aware Retry Queue in Python for Resilient Scraping","Learn how to implement a proxy-aware retry queue in Python that handles 429 and 503 responses with exponential backoff, jitter, and automatic proxy rotation for resilient web scraping.",1796251609216]