Proxy or Redirect Private Downloads? What It Actually Costs
A discussion on r/node on November 20 raised a question worth examining: What happens to your bandwidth bill when you stream every private download through your application backend? It's a fair concern. If every downl
A discussion on r/node on November 20 raised a question worth examining:
What happens to your bandwidth bill when you stream every private download through your application backend?
It's a fair concern.
If every download passes through your application server, you're adding work to your infrastructure. But the actual cost depends heavily on where your files live, where your server runs, and what guarantees you need.
Sometimes proxying costs more. Sometimes the difference is smaller than people expect. And sometimes choosing the cheaper option means giving up an important access guarantee.
I've been working through this problem while building private file delivery infrastructure. Here is what I learned.
Prices checked November 21, 2026. All prices are USD, at the time of writing.
1. The decision is not really about bandwidth
There is one question that should decide whether you proxy or redirect:
Does withdrawing access need to take effect before the download URL expires?
If the answer is no, redirecting to a short-lived presigned URL is usually reasonable.
If the answer is yes, proxy the download.
These are different access guarantees.
Redirect: access lasts until the URL expires
Your application checks permissions and generates a presigned URL.
The browser follows the redirect and downloads directly from storage.
The problem is what happens after access is revoked.
Suppose you generate a URL valid for 10 minutes. Two minutes later, you revoke the user's permission.
The URL still works for the remaining eight minutes.
Your application has already handed control to the storage provider. It cannot recall that URL.
The revocation window is therefore the presigned URL's remaining lifetime.
Proxy: check permissions on every request
With a proxy, the application handles the download request, checks whether access is still allowed, and streams the bytes from storage to the client.
Consider this measured test:
- Bob requests
bytes=0-4and receives HTTP 206. - Alice revokes Bob's access.
- Bob requests
bytes=5-9. - The server checks permissions again and returns HTTP 404.
That is the important difference.
The revocation window is one request.
There is one qualification: if a large HTTP 200 response is already streaming, revocation does not magically terminate that connection. The existing transfer can finish. Revocation takes effect on the next request.
For private downloads, return 404 after revocation rather than 403. A 403 tells the requester that the resource still exists but access is forbidden. A 404 avoids confirming that the file exists.
2. What does proxying actually cost?
Let's look at two storage options that matter for this comparison.
AWS S3
AWS charges for data transferred out to the internet.
For US regions, the first tier is approximately $0.09 per GB for the first 10 TB per month, after the applicable 100 GB monthly free allowance.
That free allowance is shared across eligible AWS services and regions, rather than being a separate allowance for each service.
For these examples, I'm using 1 TB = 1,024 GB and the first-tier rate of $0.09 per GB.
| Monthly data delivered | Approximate cost |
|---|---|
| 100 GB | $0 |
| 1 TB (1,024 GB) | $83 |
| 5 TB (5,120 GB) | $452 |
These calculations assume the 100 GB allowance is available and use the first-tier rate. Actual billing depends on the applicable pricing tiers and other account usage.
Sources:
Now comes the interesting part.
If your application server runs in the same AWS region as your S3 bucket, transfers directly between S3 and EC2 are free.
This is true even when the resources are in different Availability Zones.
The important exception is when another chargeable service sits in the network path.
A common example is a NAT Gateway.
If your EC2 instance accesses S3 through a NAT Gateway, the gateway charges for the traffic it processes. This is not an S3-to-EC2 cross-AZ data transfer charge. It is a NAT Gateway processing charge.
The solution is an S3 VPC Gateway Endpoint.
It allows your application to communicate with S3 without routing that traffic through an internet gateway or NAT device. Gateway endpoints have no additional usage charge.
AWS documents this explicitly.
Sources:
Your server still sends the downloaded bytes to the internet.
That outbound traffic is billed according to the applicable EC2 data transfer pricing.
In other words, when everything is correctly placed, proxying does not necessarily mean paying for two separate internet transfers.
What you add is the work performed by your application infrastructure:
- Compute.
- Open connections.
- Network throughput.
- Capacity planning.
- Operational complexity.
Cloudflare R2
R2 changes the calculation.
Cloudflare charges:
- $0.015 per GB-month for standard storage.
- $0.36 per million Class B operations.
- $0 for internet egress.
Yes, zero egress fees.
If you redirect users directly to R2, the storage provider does not charge you for outbound bandwidth.
But if you proxy those downloads through a server hosted elsewhere, that server still has to send the bytes to the internet.
You have now moved the bandwidth cost from the storage provider to your hosting provider.
You are also giving up one of R2's most attractive economic properties: free egress.
This is where proxying can genuinely cost more.
I am deliberately not quoting a specific hosting provider's bandwidth price here. Those prices need to be checked against the actual provider and plan at the time of deployment.
Source: Cloudflare R2 Pricing.
3. There is another cost: you cannot simply cache revocable downloads
There is an important consequence of proxying private files.
If revocation must take effect on the next request, a CDN must not replay an old authorized response after access has been withdrawn.
For revocable private responses, use:
Cache-Control: private, no-store
This means the CDN cannot absorb that download traffic through ordinary response caching.
Every request needs to reach the authorization path.
We actually encountered this issue in an earlier implementation. Our own version failed this exact scenario, which we recorded as attack B3.
This is worth understanding when estimating the economics.
A proxy is not simply a CDN sitting in front of your storage. If you need immediate revocation at the next request, caching the response defeats the guarantee.
4. Streaming does not mean buffering the entire file
Another misconception is that proxying requires loading the entire file into server memory.
It doesn't.
A properly implemented proxy streams bytes from storage to the client.
The data flows through the application, but memory usage stays approximately flat rather than growing with the file size.
This makes a substantial difference when handling large files.
However, it does not eliminate the need to manage connections, throughput and server capacity.
5. If you proxy, Range becomes your responsibility
This is where things get more interesting.
When you redirect directly to object storage, the storage provider handles HTTP Range requests.
When you proxy, your application becomes responsible for preserving that behavior.
And clients rely on it more often than you might think.
A video element can request a specific byte range before allowing the user to scrub through the video.
A PDF reader can request the final bytes first to inspect document structure.
If your proxy mishandles these requests, the file can appear corrupted even though the underlying object is perfectly fine.
We tested this using a 26-byte object.
Here is what the implementation needs to handle.
Valid and satisfiable ranges
| Request | Expected response |
|---|---|
bytes=0-4 |
206 |
bytes=-4 |
206 |
bytes=20-999 |
206 |
The last example is valid. The requested range extends beyond the object, so the server returns the available bytes through the end of the representation.
Requests that our implementation ignores
Not every Range request needs to result in a 206 response.
RFC 9110 explicitly permits a server to ignore the Range header.
Our measured results:
| Request | RFC classification | Measured response |
|---|---|---|
bytes=9-4 |
Invalid range | 200 |
bytes=-0 |
Valid but unsatisfiable | 200 |
bytes=abc |
Invalid range syntax | 200 |
items=0-4 |
Unsupported range unit | 200 |
bytes=0-4,10-14 |
Valid multiple ranges | 200 |
These results illustrate three different cases.
First, bytes=9-4 is invalid because the last position is smaller than the first.
Second, bytes=-0 is syntactically valid, but a suffix range of zero bytes is not satisfiable.
Third, bytes=0-4,10-14 is a valid request for multiple ranges. Our implementation ignores it and returns the complete representation with HTTP 200.
The RFC permits ignoring the Range header. The measured responses are therefore valid.
A genuinely unsatisfiable range
The last request is different:
Range: bytes=99-120
The object is only 26 bytes long.
The request is syntactically valid, but none of the requested bytes exists.
The correct response in our implementation is HTTP 416:
HTTP/1.1 416 Range Not Satisfiable
Content-Range: bytes */26
The relevant standard is RFC 9110, Sections 14.1 and 14.2.
Multiple ranges are not something to approximate
There is another easy mistake.
Suppose a client requests:
Range: bytes=0-4,10-14
Returning only the first range with a 206 response is not a valid substitute for the requested representation.
The client may reconstruct the file incorrectly.
Our implementation deliberately ignores multiple-range requests and returns the complete representation with HTTP 200.
RFC 9110 permits a server to ignore the Range header.
One header worth remembering
When range support is enabled, return:
Accept-Ranges: bytes
This communicates that byte-range requests are supported.
There is an important qualification in our implementation: when a download limit is active, Filelayer returns:
Accept-Ranges: none
In that situation, range requests are not advertised as supported. This is intentional behavior, not a contradiction.
There is also an audit consideration.
The authorization decision and download counter happen before bytes start moving.
If the connection dies halfway through, the system has recorded an allowed read, not a successfully completed download.
That distinction matters if you use download counters for billing, compliance or customer-facing analytics.
6. A practical approach: choose per file
I don't think applications need to make this an all-or-nothing architectural decision.
Different files have different requirements.
Here is the split I would use:
| File type | Recommended delivery | Reason |
|---|---|---|
| Avatars | Redirect | A short residual access window is acceptable |
| Thumbnails | Redirect | Low sensitivity and simple delivery |
| Large media | Redirect | Direct storage delivery avoids application throughput |
| Contracts | Proxy | Revocation must take effect on the next request |
| Customer documents | Proxy | Access is tied to current authorization |
| Paid downloads | Proxy | Access withdrawal is part of the product promise |
| Public assets | Public/CDN | No signing or private delivery needed |
The important thing is to make the decision based on the actual access guarantee, not on an assumption that one delivery method is always cheaper.
7. The actual trade-off
Let's summarize.
Redirecting:
- Less work for your application servers.
- Direct delivery from storage.
- Short-lived URLs provide bounded access.
- Revocation cannot invalidate an already-issued URL before expiration.
Proxying:
- Authorization can be checked on every request.
- Revocation applies to the next request.
- Your application handles streaming, Range requests and connections.
- Server throughput and compute become part of the cost.
- Private responses cannot be cached if immediate revocation is required.
Neither option is automatically the right answer.
The correct choice depends on the guarantee your application is making to its users.
Final thought
The original bandwidth question is valid.
But the cost of private file delivery is not just the price per GB. It is also the cost of the access guarantee you promise.
If a user revokes access to a contract, should someone who already received a download URL still be able to access it for another ten minutes?
For an avatar, that might be perfectly acceptable.
For a confidential customer contract, it might not be.
That is the decision I would make first. Then I would calculate the infrastructure cost.
I documented the implementation details, including the revocation behavior and Range test cases, in our private file delivery guide.
Disclosure: I am building Filelayer, the file layer for SaaS applications. Proxy is our default delivery mode. Redirect requires explicit opt-in and typed acknowledgement of its revocation window. The goal is to make the trade-off visible rather than hide it.
Sources
- AWS S3 Pricing, data transfer pricing.
- AWS EC2 On-Demand Pricing, outbound internet transfer pricing and free allowance.
- AWS Global Network FAQs, aggregated free data transfer allowance.
- AWS S3 Gateway Endpoints, gateway endpoint pricing and behavior.
- AWS re:Post: NAT Gateway transfer charges, NAT Gateway cost reduction.
- Cloudflare R2 Pricing, storage, operations and egress.
- RFC 9110, HTTP Semantics, Sections 14.1 and 14.2, Range Requests.
Pricing checked November 21, 2026. At the time of writing.
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.