4 ms·
>> Varying your content based on mobile User-Agent (or any User-Agent actually) renders public caches almost impossible to get right. Interesting. What would y
by lhnz 15y ago
>> Varying your content based on mobile User-Agent (or any User-Agent actually) renders public caches almost impossible to get right.
Interesting. What would you recommend doing instead, supposing, for example, that you are meant to be returning a different set of items depending on a device identifier, and that you have to support 100s of devices? Should this be considered a different resource instead of a different representation?
Also, can you point me to a nice resource about public caches?
Thanks!
- hcarvalhoalves 15y agoAt your cache layer (e.g. Varnish), you would need some VCL to collapse all the hundreds of User-Agents options into something sane like "X-Device", feed this header to your backend, and vary the content based on that instead. This way you can cache just a few representations per resource (e.g., "Desktop", "Mobile", "Tablet", etc.) instead of several hundred. The problem, of course, is maintaing this list of User-Agents. On his mobile example, it's much easier to simply be pragmatic and serve content for different devices at differents URIs/domains altogether. It doesn't break if you can follow some kind of convention, such that the URLs from one map directly to the other (for instance, mysite.com/news/article -> m.mysite.com/news/article) and then you issue redirects accordingly.