AMP experiment non-results

April 27th, 2018
tech
A couple months ago I made an AMP version of my site, and set up a 50-50 A/B test to see how it worked. Unfortunately, the experiment had issues: there were 30% more AMP loads than non-AMP loads in what was supposed to be a 50-50 page diverted experiment. What went wrong?

I set up my experiment as:

http {
  ...
  split_clients $msec $amp {
    50% ".amp";
    * "";
  }
  server {
    ...
    rewrite ^(/p/(?!index)..*) $1$amp last;
  }
}
What this did was take visitors requesting /p/some-post and half the time serve them the contents of /p/some-post.amp instead. Looks good, right?

Unfortunately, I also (as you're recommended to do) linked between my AMP and non-AMP pages with <link rel=canonical "/p/some-post"> on my AMP page and <link rel=amphtml "/p/some-post.amp"> on my non-AMP page. Search engines, though probably only Google right now, use that link to sometimes show people the AMP version of a page in search, and hence the extra page views.

The right way to do this would have been to not include the rel=amphtml link, and to make /p/some-post.amp inacessible by direct url. Then users would be diverted on each load and everything would be fine.

Except for another problem, which is that Google expects that a page wil not jump back and forth between being AMP and not. Google preloads AMP pages, and it looks like it does this in multiple passes where it first sees that a page is AMP and then later caches the current version. So if it sees AMP initially, and then when serving it to a user gets non-AMP, the prerendering is broken. The user sees a flash of this error page:

and then is quickly redirected to the canonical (non-AMP) page.

This breaks the main advantage of AMP, which is that it can be safely cached and preloaded.

I could re-run this experiment based on a hash of the url, which would be stable and so not mess up Google, but I'm feeling done and have turned it off instead. People will get the non-AMP versions of pages normally, and only get AMP versions when they're coming from somewhere that interprets rel=amphtml links. [1]

(Taymon pointed out that this would be a problem when I first proposed the experiment, but I kept putting off dealing with it until I saw the error page flash by me when clicking on a link to my site on mobile.)


[1] Or if you manually append .amp to urls.

Referenced in: Trying out AMP

Comment via: google plus, facebook, substack

Recent posts on blogs I like:

Elixir's Last Dance

On May 18th, the contra dance band Elixir had their last gig ever. The dance was packed: there were three hundred people. It was the only dance BIDA has ever done where they sold tickets. People flew from across the country just to hear Elixir play one la…

via Lily Wise's Blog Posts June 5, 2025

Body Language For Trans People

When I first came out as trans, resources for trans people were full of advice about body language.

via Thing of Things June 2, 2025

Workshop House case study

Lauren Hoffman interviewed me about Workshop House and wrote this post about a community I’m working on building in DC.

via Home April 30, 2025

more     (via openring)