Very interesting observation.
This motivated me to do some research (I work for CDN provider myself).From what I can tell, "Vary:User Agent" will prevent Caching (as it basically marks the content as "personalized" - even if for a group of visitor)
How about creating a different URL structure for mobile users (i.e. identifying the client and sending all mobile traffic to mobile.mydomain.com)?
After reading Google Documentation I understand your reasoning but I still think that combining Vary:User-Agent and Caching will almost certainly lead to false-positives.
GL
On Tuesday, October 16, 2012 11:57:14 PM UTC+2, Jody wrote:
Part of the Google documentation for Smartphones suggests using an HTTP Vary: User Agent header to send a potential signal to not cache the mobile and desktop versions when they are the same URL. This came out in a June announcement from Pierre Far.
The Vary HTTP header
The Vary HTTP header has two important and useful implications:
- It signals to caching servers used in ISPs and elsewhere that they should consider the user agent when deciding whether to serve the page from cache or not. Without the Vary HTTP header, a cache may mistakenly serve mobile users the cache of the desktop HTML page or vice versa.
- It helps Googlebot discover your mobile-optimized content faster, as a valid Vary HTTP header is one of the signals we may use to crawl URLs that serve mobile-optimized content.
On Tuesday, October 16, 2012 2:11:14 PM UTC-7, Bryan McQuade wrote:
> For more options, visit this group at
> http://groups.google.com/group/page-speed-discuss?hl=en.
--
You received this message because you are subscribed to the Google Groups "page-speed-discuss" group.
To view this discussion on the web visit https://groups.google.com/d/msg/page-speed-discuss/-/XhEMDT8GcUoJ.
Jody - thanks for sharing this.Bryan I see your point about using different URL but I don't think a redirect is a "must" here (how about a providing a popup for mobile visitor that can direct them to the mob. subdomain, if they so choose)
As to sitemap xml file... I guess this could be done, but honestly it will probably be simpler to do the same thing with dynamic parameters and then explain the redundancy to Google via Webmaster Tools... (or am I wrong about this?)
"Canonical" tag will also work and as far as I know it can be used cross-domain.Finally, I think that even "noidexing" the redundant mobile version will not hurt SEO or effect Google SERP results.Anyway, Caching wise, I think that any solution that can differentiate between the 2 versions of the same object (i.e. providing different and uniqe URL for regular and mobile content) is a good one.Just as long as it can be combined with relevant HTTP header - something that can allow Caching... (i.e. Max-Age:XXXX)The company I work for uses a patent pending "behavior learning" algorithm to deal with dynamic Caching (quite successfully I might add)...This is a gist of it: Dynamic Caching Algorithm and I think it maybe useful to look at.
As I've said, the current heuristics will not help Cache any User-Agent:Vary objects (just like Akamai wrote - this can create issues when dealing with personalized content).
Maybe, by introducing additional steps into the process (like checking sitemap xml for preferment signals or recognizing universally accepted parameters) the algorithm can be improved?
On Tuesday, October 23, 2012 10:44:17 PM UTC+2, Jody wrote:Thanks everyone for these replies and looking into this. The XML sitemap and <head> section of the HTML document offer an opportunity to put a link "alternate" pointing to the mobile URL. In conjunction, the mobile page would have a link "canonincal" pointing to the desktop page. I am not sure how this would help with the caching aspects of the pages, but maybe you know more? These don't help with the caching piece, but might it be better to forego this part with CDN's?Just to update as well, I got some of the akamai documentation which outlines how they look at this:Why don't Akamai servers cache objects if the origin server's Vary header contains anything other than Accept-Encoding?
This is necessary to prevent different versions of content from being cached and then later served to end users for which they are not intended. For instance, this prevents pages in one language from being cached and served to users of another language, or pages designed specifically for a certain browser from being cached and then served to users on another browser.
The HTTP Vary header is used by servers to indicate that the object being served will vary (the content will be different) based on some attribute of the incoming request, such as the requesting client's specified user-agent or language. The Akamaiservers cannot cache different versions of the content based on the values of the Vary header. As a result, objects received with a Vary header that contains any value(s) other than "Accept-Encoding" will not be cached. To do so might result in some users receiving the incorrect version of the content (wrong language, etc.)
An "Accept-Encoding" value to the Vary header is the exception to this rule only when it relates to serving the object compressed. Since compression does not change the content of the object (only its size for transfer), an object that varies only by its compression can be safely cached.
To summarize, Akamai servers will cache the object, based on the configuration settings, in either of the following cases:
- If "Vary: Accept-Encoding" is received and the content is served compressed ("Content-Encoding: gzip").
- If no Vary header at all is received.
More detailed description of Vary and Accept-Encoding header interaction:
"Vary: Accept-Encoding" from the origin server indicates that the object served varies based on values received in the Accept-Encoding header of the incoming client request. For instance, the Akamai servers send the header "Accept-Encoding: gzip" in their forward requests to tell the origin server that gzip compression is supported. It is expected that the origin server will respond with the "Vary: Accept-Encoding" and "Content-Encoding: gzip" headers if serving the object compressed, or with no Vary header at all if serving the object uncompressed. Any other combination, such as other values in the Vary header or no "Content-Encoding: gzip" header in the response, indicates that the object varies in some way other than compression (that its actual content may be different), and therefore should not be cached.
> For more options, visit this group at
> http://groups.google.com/group/page-speed-discuss?hl=en.
--
You received this message because you are subscribed to the Google Groups "page-speed-discuss" group.
To view this discussion on the web visit https://groups.google.com/d/msg/page-speed-discuss/-/XhEMDT8GcUoJ.
To post to this group, send email to page-spee...@googlegroups.com.
To unsubscribe from this group, send email to page-speed-discuss+unsub...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/page-speed-discuss?hl=en.
--
You received this message because you are subscribed to the Google Groups "page-speed-discuss" group.
To view this discussion on the web visit https://groups.google.com/d/msg/page-speed-discuss/-/EG5PonyC88gJ.
Hi Christian,The key point to understand is that the response Akamai sees and the response Google (or browsers) see is not the same one.Akamai, and other CDNs, are effectively extensions of your infrastructure. You control the behavior of the Akamai Edge when it receives a request, and can therefore dictate how to handle caching of a response on the edge, and manipulate the headers passed on from the Akamai edge to the client.Google, on the other hand, is just a client, and more specifically it's outside your control. As a result, the only way you can communicate something to Google - like the fact you serve different content to a mobile and a desktop website - is through HTTP. There are also caching forward proxies, like those often used by ISPs, which are also outside of your control, so again you have to use the HTTP Vary header to tell them not to serve content cached during a desktop client request to a mobile client.The way to bridge this gap is through Akamai configuration. Assuming your origin indeed returns different content for mobile and desktop content, and assuming your content is cacheable in the first place, you'd want to do this:1) Return a "Vary: User-Agent" from your origin2) Configure Akamai to ignore the Vary: User-Agent, but not remove it3) Configure Akamai to cache based on the "is mobile" characteristic of the incoming device, using Aqua Ion Mobile's Device Characteristics feature. When the next request arrives, if it has the same "is mobile" flag, the response will be returned from cache. If not, it'll be routed through to the origin, and then its response will be cached for the new "is mobile" value.Note that 1-2 can be replaced with not returning a Vary: User-Agent and adding that header on the edge.I'd suggest contacting Akamai support (or the services person you work with) to walk you through doing so in the UI.Cheers,Guypo--
On Thursday, May 9, 2013 8:32:28 AM UTC-4, Christian Oliveira wrote:Hi Guy,
Thanks for adding some light to this problem :)Google specifically recommends to use "Vary: User-Agent" header for non-responsive mobile websites, that's why started to use it and discover the problem with Akamai.
I recently send a question to Google WMC to know if they still recommend using it after knowing that CDNs like Akamai won't cache the page if that header is there, and they say they do: http://www.youtube.com/watch?v=va6qtaiZRHgCould you explain further your solution proposed in 1) ?Thanks in advance!Christian
El jueves, 11 de abril de 2013 00:50:38 UTC+2, Guy Podjarny escribió:Hi,Sorry for the late response, I only stumbled onto this thread now.I work for Akamai and just wanted to point out a few things.1) If your goal is mostly to send a "Vary: User-Agent" header to the user (not to Akamai), then you can simply configure Akamai to ignore the Vary header (it should be a simple checkbox under the "Optional Features") and then return "Vary: User-Agent" from your servers. There are also ways of configuring Akamai to add headers to the response being sent to the client, but in this case it'll be easier to just have Akamai ignore Vary and send it back from your origin.2) If you indeed have different content for different clients, for example use the same URL for mobile & desktop but serve different content, there are also ways to configure Akamai to have a more tuned cache key, for example caching based on whether the device is a smartphone or not. Many of the mobile specific features are packaged as part of Aqua Ion Mobile (http://www.akamai.com/dl/brochures/aqua_ion_mobile_pb.pdf).3) I agree Vary is broken, which is why we currently need to rely on configuration for the edge instead of Vary. At some point in the future maybe "Key" (http://tools.ietf.org/html/draft-fielding-http-key-00) would help us out here, though Key has some pretty major impact on cache lookup time so probably can't be implemented quite as-is. Various parties are experimenting with Key right now, if we manage to find the right way to make it work, we may not need to have this conversation in the future...Cheers,Guypo
You received this message because you are subscribed to a topic in the Google Groups "page-speed-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/page-speed-discuss/kk-_1xslHrE/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to page-speed-disc...@googlegroups.com.
Visit this group at http://groups.google.com/group/page-speed-discuss?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.