Fix false cache hits for file downloads (issue #367)
This PR addresses the issue where some clients (like the R bindings) were receiving corrupt/compressed data because the proxy was serving cached gzip/brotli responses to clients that didn't support them.
What I changed in
app-next/src/app/api/proxy-file/route.ts
1 - Forwarded Accept-Encoding: The proxy now passes the client's original encoding preferences to the upstream server. This ensures the upstream only sends compressed data if the client actually asked for it. 2 - Added Vary: Accept-Encoding: I added this header to the proxy's response. This tells CDNs and intermediate caches to store separate versions of the file based on the client's encoding support, preventing "cross-client" cache contamination. 3 - Passed through Content-Encoding: If the upstream does return compressed data, the proxy now correctly forwards that header so the client knows it needs to decompress the response.
Testing done:
1 - Ran a full npm run build to make sure the route compiles correctly. 2 - Verified with tsc --noEmit and eslint (0 errors). 3 - Double-checked the logic to ensure we aren't adding unnecessary headers to non-binary files. Fixes #367