cloudflare-apps / ideas

A list of Cloudflare App Ideas (in Issues)
https://www.cloudflare.com/apps/developer/docs/getting-started
43 stars 12 forks source link

Internally Redirect/Rewrite to Different URL #276

Closed praisedpk closed 4 years ago

praisedpk commented 7 years ago

Background: Pre-compression of static resources, and Object Storage.

The issue I am facing is that DigitalOcean Object Storage allows uploading pre-compressed files and set a custom Content-Encoding header. User can upload multiple versions of static files, that can be brotli compressed, gzipped and raw.

The idea is that I want to rewrite/redirect it (without issuing a 301/302/307 response) to a different static URL based on Accept-Encoding capabilities of the User-Agent (or this can be generalized to allow the APP user to match any criteria, i.e User-Agent string).

For example, the default URL will be like: https://domain.com/static/css/styles.css

If User Agent accepts brotli compression based on Accept-Encoding header, internally rewrite/redirect it to (without issuing a 301/302/307 response): https://domain.com/static/css/styles.css.br

However, if brotli is not supported, but the browser accepts gzip, internally rewrite it to gzip precompressed file: https://domain.com/static/css/styles.css.gz

Thanks.