dotnet / dotnet/aspnetcore

`Accept-Ranges` should not be returned when output caching is used

Open
#45,999 10 comments 0 reactions 0 assignees View on GitHub
area-middleware feature-caching feature-output-caching
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 6h
Merged PRs (30d)
290

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Describe the bug

When output caching is used with static content, the `Accept-Ranges` header is returned, but requests with the `Ranges` header are not served correctly.

### Expected Behavior

The `Accept-Ranges` header should not be set when output caching is enabled. The `Ranges` header in requests should be ignored when output caching is enabled.

### Steps To Reproduce

This project has a simple repro:
https://github.com/jonpayne/AspNetCacheIssue/tree/main/src

Using this example:
```bash
curl -s -D - https://localhost:5000/test.txt -H "Range: bytes=0-32" // returns a range
curl -s -D - https://localhost:5000/test.txt -H "Range: bytes=0-40" // returns a different range
curl -s -D - https://localhost:5000/test.txt // returns the full content
curl -s -D - https://localhost:5000/test.txt -H "Range: bytes=0-32" // returns the full content (unexpected)
curl -s -D - https://localhost:5000/test.txt -H "Range: bytes=0-40" // returns the full content (unexpected)
```

### Exceptions (if any)

_No response_

### .NET Version

7.0.101

### Anything else?

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.