Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Many CDNs do not support arbitrary Vary headers. Cloudfront, for example asks you to create a "Cache and Origin Request Policies" that gives you the ability to choose what headers are part of the request that gets sent to your origin. These will get added to the cache key, but it is a static list based on the request to the origin and not the response.

Akamai is another case where Vary is harmful, from their docs [1]:

    > As the content in response may be different for the same URL,  
    > Akamai  edge servers don't cache responses that include the Vary header, 
    > even if the content is cacheable by definition. The only exception is 
    > the case where the Vary header's value is Accept-Encoding and the
    > Content-Encoding header's value is br or gzip – edge servers cache 
    > such responses, applying the caching rules you defined in your property.
Cloudflare's docs do seem to indicate they support the Vary header as does Fastly. But one should read the docs of their CDN to find out the behavior. Do not assume Vary is supported.

https://techdocs.akamai.com/property-mgr/docs/rm-vary-header

 help



It's often better to implement your caching logic at the Edge than just going with Vary support. Vanilla Vary support leads to cache dilution. Accept (and other headers you might include in vary) may take many different values that you want to tie to a single cache entry.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: