How the server knows when to serve the amplifier page

I understand that there will be a version of the site with HTML for desktop devices and then AMP pages.

Is there anything I need for the site to serve AMP content on mobile devices?

+7
redirect amp-html
source share
2 answers

Good question!

Summary:

  • AMP does not provide automatic redirects, only the necessary markup for its search engine (and, possibly, other websites / applications / search engines to send its users to the AMP page
  • You can use the old methods of redirecting mobile users to mobile sites, usually by detecting mobile user agents and redirecting them through 301/302 redirecting to the AMP page
  • Redirecting mobile users is not worth doing, because the above old methods seem to suck

Full answer:

From the perspective of Google and the search engine results page (SERP), you need to include this in your desktop layout:

<link rel="amphtml" href="https://www.example.com/url/to/amp/document.html"> 

and this is in your AMP markup:

 <link rel="canonical" href="https://www.example.com/url/to/standard/document.html"> 

so that Google and other high-traffic networks such as Twitter, LinkedIn, or Pinterest , respectively, detect amphtml signatures and direct mobile browsers on the AMP page. I would say that Facebook, but since AMP is a product of competitors Facebook Instant Articles , I suspect that they will carry heels.

AMP is, of course, a completely different animal, being both open source and web technology, and not a native content application platform, but web and native platforms are opposed to each other, and Google provides a large number of applications, this is clear from technologies such as ServiceWorker, which they promote on the Internet as a content platform, which should not be surprising, because the time spent on Facebook or Apple apps is the time spent searching Google and its advertising, from which Google receives its income.

But I'm distracted: it is obvious that this rel="amphtml" will only instruct Google and others to redirect this result to mobile users from their pages. This is because the redirection policy was not the goal of Google or the AMP team, which would prefer a world in which everyone passes through Google or another major player, rather than directly or directly connected to email or something else.

In theory, one day it can be implemented at the browser level, but it requires browser vendors long enough to standardize the basic layout / styling properties and JavaScript APIs, not to mention random non-standard considerations, since AMP is currently time. Apple will pull its heels when it comes to the browser, because it will compete with its News .

We probably expect that the AMP redirection will be implemented in the Chrome browser (and therefore in Opera), but even this may not be for long. Thus, in order to force mobile devices to redirect to AMP pages, not your standard ones, you ultimately need to set up a web server to sniff for mobile user agents (or less common MIME types) and redirect (use 302 for SEO ) to pages AMP

It may seem a bit of a regression of past habits, and you would be right to think so. Redirecting will immediately slow down the journey a little, although AMP is valuable for optimizing it on the page, as well as for HTTP response / transmission time. Until the current zenith of responsive web design, this is how mobile users will be served, especially on WAP days. Websites will serve as a mobile version supported by a subdomain, such as mob.website.com or m.website.com . There were flavors of XHTML targeting to mobile devices that are still used by Google+ for its β€œmain” pages (note DOCTYPE). These "main" pages are reserved for low-resolution devices, as can be seen from this line:

 <link rel="alternate" media="only screen and (max-width: 640px)" href="/app/basic/+SOME_PAGE"> 

This approach may even serve as a source of inspiration for AMP.

This redirect practice, I hope, is not a problem for you because you probably intend to use amp.website.com or perhaps a subdirectory for your AMP pages.

Since all websites should react in any case - from an SEO point of view , but because targeting only to mobile devices is complicated by the unreliability of redirect methods and using user agents and MIME types as a detection method - it may be tempting to try to evaluate the connection speed or the physical location of the visitor.

Then, if the connection speed is slow, or if the user is far from your source server, it is best to redirect them to the AMP page (since it is served from Google CDN and uses HTTP / 2 + heavy caching for fast content serving).

However, any CDN can be used for all pages to deliver them faster to everyone, and not just slow connection users or people located far from your source server; the AMP dot only partially delivers content via the CDN and perhaps more about serving responsibly designed pages on devices that are well known for their crappy JavaScript runtimes, such as mobile phones.

Ultimately, I will not apply redirection to all mobile users. I would leave it with Google to direct visitors arriving through my search engine to be sent to AMP pages. If AMP is going to catch and be a long-lived product, browsers will eventually implement it.

Think about it, if you serve content on mobile devices, it may be irresponsible to serve AMP pages for people using older Windows Phone or Blackberry devices whose browsers may not even use AMP properly .

There is a lot to think about, but I hope that I have provided an answer to your question, and if not, at least some considerations should be kept in mind before taking the right answer for your product.


For more information on individual mobile sites, you can read this topic documentation provided by Google.

Examples of how to configure the web server to detect mobile user agents and send them to another subdomain, you can find articles or code examples quite easily if you are looking for them.

+16
source share

Just to complete, I used the following redirects to serve AMP pages for specific user agents, this is .htaccess for the apache web server with mod_redirect enabled:

 <IfModule mod_rewrite.c> RewriteBase / RewriteCond %{REQUEST_URI} !/amp/$ [NC] RewriteCond %{HTTP_USER_AGENT} (android|blackberry|googlebot\- mobile|iemobile|iphone|ipod|\#opera\ mobile|palmos|webos) [NC] RewriteRule ^([a-zA-Z0-9-]+)([\/]*)$ https://www.yoursite.com/$1/amp/ [L,R=302] </IfModule> 
0
source share

All Articles