responsive-and-fast-implementing-high-performance-responsive-design
responsive-and-fast-implementing-high-performance-responsive-design
responsive-and-fast-implementing-high-performance-responsive-design
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
The Vary header instructs the cache to add a given request header to<br />
its cache key. For instance, a server may choose to only gzip a response<br />
for clients that support it, as indicated by their Accept-Encoding<br />
header. Since it doesn’t want downstream proxies to serve a compressed<br />
response to a client that doesn’t support it, it returns Vary:<br />
Accept-Encoding with its response.<br />
For RESS, the most relevant uses are to Vary by User-Agent, which is<br />
the formal way an incoming device declares itself; <strong>and</strong> Cookie, often<br />
used for custom identifiers. Unfortunately, User-Agent <strong>and</strong> Cookie<br />
are probably the longest request headers, <strong>and</strong> each can hold an extremely<br />
large number of values—many more than the granularity we<br />
actually want to split our content by.<br />
This means the use of Vary for either header will likely create excessive<br />
cache fragmentation (when every cache entry is applicable to a small<br />
number of requests), <strong>and</strong> effectively disable third-party caches. In fact,<br />
many caching proxies explicitly won’t bother trying, <strong>and</strong> will simply<br />
not cache responses that use Vary on Cookie or User-Agent. As a<br />
result, the only practical value in using Vary: User-Agent is to indicate<br />
to search engines that your page may serve different content to<br />
different clients.<br />
The Cache-Control header guides downstream proxies on how to<br />
cache a response, <strong>and</strong> supports separate instructions for shared proxies<br />
<strong>and</strong> clients. For instance, specifying Cache-Control: private tells<br />
downstream cache proxies to avoid caching a RESS response, while<br />
still allowing the client (for which we tuned the response) to cache it.<br />
Given the Vary header limitations, the caching effect of Cache-<br />
Control: private <strong>and</strong> Vary: User-Agent is practically the same.<br />
In summary, with today’s technology, using RESS implies that the best<br />
we can do is disable downstream caching proxies. However, a new<br />
proposed st<strong>and</strong>ard, the Key header, hopes to change this in the future.<br />
The Key header proposes a way to explicitly state the variables to include<br />
in a cache key, <strong>and</strong> do so in a st<strong>and</strong>ardized way. Key is not yet<br />
supported by any notable caching tool or service, but backing for it<br />
has been growing, which will hopefully lead to actual adoption.<br />
RESS <strong>and</strong> Caching | 45