Open manoj-makkuboy opened 5 years ago
I do this in layers in front of imaginary to keep it "intentionally stupid". Part 1 is using skipper
to modify the route back to imaginary. In front of that I have a bit of logic in my http cache to be able to mutate caches (with the same url) based on just this.
I see several complications with this approach, for those who are using a CDN. Content-Negotiation can make for a terrible cache strategy (even the order of the Accept header will result in many cache-misses) or terrible cache handling (Serving webp because it was requested first and leaving every other browser after that with an unsupported image).
However I can understand that there are situations where this would be beneficial especially when the content-negotiation can be done properly. HTTP has a pretty neat thing for content-negotiation, the HTTP Accept header. The User-Agent isn't ideal.
This would be a rather simple change:
PR welcome.
I see several complications with this approach, for those who are using a CDN. Content-Negotiation can make for a terrible cache strategy (even the order of the Accept header will result in many cache-misses) or terrible cache handling (Serving webp because it was requested first and leaving every other browser after that with an unsupported image).
You shouldn't create a cache key blindly. It took me a while to get this right, but it serves me very well and I account for a few things based on either client hints via headers or polyfilled as cookies.
Try "Vary: accept"
How about support for automatic format conversion based on user agent. Webp seems to be the preferred format on supported browsers like chrome. So, wouldn't it be nice to have an option which enables the automatic format conversion based on user-agent (browser)