Common Pitfalls of the Vary Header


#1

###Problem #1: Intermittent Compression or Inconsistent responses. Only one version (or the wrong version) of the object is being cached and delivered to users.**

####Is the Vary Header set only on compressed objects coming from your origin?
Make sure your Vary header is set on all responses coming from your origin (on both uncompressed and compressed objects) so the cache will know there are variations of the object when it makes a request to your origin. If the Vary header is not included in the origin response, Fastly will cache the first version of the object it retrieves and deliver that version to all subsequent requests, leading to intermittent compression.

####Have you recently changed your Vary settings?
You may need to perform a purge if you’ve recently made a change to your Vary header; this will ensure that the cache nodes will follow your new settings.

###Problem #2: Your Hit-Ratio has plummeted and an object doesn’t appear to be caching at all.

If you are Varying on a header with a lot of variations (ie, Cookie, User-Agent), the cache will store and deliver each unique object (Fastly stores up to 200 variations of an object). You can normalize or limit the possible values you’re varying on to make the object more cacheable. For examples of how to normalize your Vary Header, see the second half of Best Practices for Using the Vary Header