Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How/why AMPs might break when viewed on a cache #7430

Merged
merged 8 commits into from Jun 27, 2017

Conversation

ithinkihaveacat
Copy link
Contributor

Short document listing some common reasons why an AMP might behave differently when viewed on a cache versus the origin.

Probably not the right place for it, but couldn't think of a better one.

/cc @ericlindley-g

@dknecht
Copy link
Contributor

dknecht commented Feb 8, 2017

This is good.

Adding:
ampproject/ampbench#11
ampproject/ampbench#12

I wonder if we can also add a check for proper CORS settings?

@@ -0,0 +1,24 @@
# AMP Cache Debugging

**Why is my doc broken on the AMP cache?**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe phrase "on the AMP cache" as "when served from an AMP cache" instead.

Would be good to phrase throughout as general AMP caches, rather than "the" AMP cache, so the guidelines aren't Google-specific

|Web fonts do not appear (fallback fonts are used)|Fonts served with incorrect MIME type|Specify an [acceptable MIME type](https://github.com/ampproject/amphtml/blob/master/spec/amp-cache-guidelines.md#mime-types-for-fonts) for fonts|
|Web fonts do not appear (fallback fonts are used)|Cache not whitelisted by font provider|Contact font provider and ask them to whitelist [all caches](https://github.com/ampproject/amphtml/blob/master/spec/amp-cors-requests.md#cors-security-in-amp)|
|Assets (e.g. fonts and images) do not appear (**HTTP origins only**)|Document uses protocol-relative URLs|Switch to absolute URLs (that is, `http://www.site.com/doc/amp`, not `//www.site.com/doc/amp`)|
|Assets (e.g. fonts and images) do not appear|Cache is unable to access assets|Ensure the Google crawler is able to access your assets and is not blocked by `robots.txt`, IP address, or user agent, etc. ([List of user agents used by Google's crawler](https://support.google.com/webmasters/answer/1061943?hl=en).)|
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment regarding making this not Google-specific. The language is straightforward to change: "Ensure that AMP crawlers are able...". Then, for the list of user agents used by these crawlers, there could be a grid of AMP caches and their corresponding user agents?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, switched to cache-neutral language in 24f85cc.

that can be problematic.

If a particular document appears and behaves as expected on your origin, but not
when viewed via the cache (how to map origin URLs to [Google's AMP Cache](https://developers.google.com/amp/cache/overview#amp-cache-url-format)),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dknecht Is there an equivalent Cloudflare document?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not at the moment. We have in our backlog.

We are actually following the same format. I am not sure if there is comparable doc on am-project.org.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@irtefa fyi

|Web fonts do not appear (fallback fonts are used)|Fonts served with incorrect MIME type|Specify an [acceptable MIME type](https://github.com/ampproject/amphtml/blob/master/spec/amp-cache-guidelines.md#mime-types-for-fonts) for fonts|
|Web fonts do not appear (fallback fonts are used)|Cache not whitelisted by font provider|Contact font provider and ask them to whitelist [all caches](https://github.com/ampproject/amphtml/blob/master/spec/amp-cors-requests.md#cors-security-in-amp)|
|Assets (e.g. fonts and images) do not appear (**HTTP origins only**)|Document uses protocol-relative URLs|Switch to absolute URLs (that is, `http://www.site.com/doc/amp`, not `//www.site.com/doc/amp`)|
|Assets (e.g. fonts and images) do not appear|Cache is unable to access assets|Ensure the cache is able to access your assets and is not blocked by `robots.txt`, IP address, or user agent, etc. (List of user agents used by [Google's crawler](https://support.google.com/webmasters/answer/1061943?hl=en).)|
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dknecht Anything that should be added for Cloudflare here?

|Web fonts do not appear (fallback fonts are used)|Fonts served with incorrect MIME type|Specify an [acceptable MIME type](https://github.com/ampproject/amphtml/blob/master/spec/amp-cache-guidelines.md#mime-types-for-fonts) for fonts|
|Web fonts do not appear (fallback fonts are used)|Cache not whitelisted by font provider|Contact font provider and ask them to whitelist [all caches](https://github.com/ampproject/amphtml/blob/master/spec/amp-cors-requests.md#cors-security-in-amp)|
|Assets (e.g. fonts and images) do not appear (**HTTP origins only**)|Document uses protocol-relative URLs|Switch to absolute URLs (that is, `http://www.site.com/doc/amp`, not `//www.site.com/doc/amp`)|
|Assets (e.g. fonts and images) do not appear|Cache is unable to access assets|Ensure the cache is able to access your assets and is not blocked by `robots.txt`, IP address, or user agent, etc. (List of user agents used by [Google's crawler](https://support.google.com/webmasters/answer/1061943?hl=en).)|
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caches should not (and do not) respect robots.txt for user invoked requests, so this should not be an issue.

The IP based blocking can, indeed, be an issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove reference to robots.txt in d8df74e.


|Symptom|Issue|Solution|
|---|---|---|
|Web fonts do not appear (fallback fonts are used)|Fonts served with incorrect MIME type|Specify an [acceptable MIME type](https://github.com/ampproject/amphtml/blob/master/spec/amp-cache-guidelines.md#mime-types-for-fonts) for fonts|
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same can also happen with images. Either a non image/ mime type or the wrong mime type.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adjusted doc to mention images in c1c054f.

@dknecht
Copy link
Contributor

dknecht commented Feb 8, 2017

A few other suggestion:

  1. It might be good to mention what to do if image are distorted.
  2. Mention the update-ping mechanism


If a particular document appears and behaves as expected on your origin, but not
when viewed via the cache (how to map origin URLs to [Google's AMP Cache](https://developers.google.com/amp/cache/overview#amp-cache-url-format)),
first open the developer console in your browser, and ensure no errors or
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the "developer console" the Chrome one? If so, please be specific - "Chrome DevTools console"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I was trying to be browser neutral but ended up being confusing--I've adjusted the language a bit in 5765a50. Should I also specifically call out Chrome?


If a particular document appears and behaves as expected on your origin, but not
when viewed via the cache (how to map origin URLs to [Google's AMP Cache](https://developers.google.com/amp/cache/overview#amp-cache-url-format)),
first open the developer console in your browser, and ensure no errors or
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this would read better if the "steps" were listed as bullets, so that it's easy to parse the info, like so:

If a particular document appears and behaves as expected on your origin, but not when viewed via the cache (how to map origin URLs to Google's AMP Cache), try the following:

  • Validate that there are no errors or warnings for the AMP page by reviewing the Chrome DevTools console.
  • Validate the structured data and AMP urls for the page by using the AMPBench tool.
  • If you still have a problem, review the table below:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switched to point form in 5765a50.

@ithinkihaveacat
Copy link
Contributor Author

@dknecht What's the distorted image problem you're referring to in #7430 (comment)?

@dknecht
Copy link
Contributor

dknecht commented Feb 24, 2017

@ithinkihaveacat Every once in awhile the google cache and cloudflare cache preform an image optimization that make image break.

I would suggest we merge this and. then improve from here. This doc is a great start.

@ericlindley-g
Copy link
Contributor

Thanks @ithinkihaveacat ! — LGTM as long as other reviewers agree

@cramforce
Copy link
Member

Can we make this appear on our docs site?

@ghost
Copy link

ghost commented Jun 8, 2017

@cramforce - Yes, I can, in the debugging section. It'll have to be merged first, then I'll do some inclusion.

Also, to be clear, are these instructions relevant to all caches, not just Google?

@@ -0,0 +1,28 @@
# AMP Cache Debugging

**Why is my doc broken on an AMP cache?**
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make this a heading level 2 (##)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 5a13ec8.

@ericlindley-g
Copy link
Contributor

Ping @cramforce — LGTY?

|Symptom|Issue|Solution|
|---|---|---|
|Web fonts do not appear (fallback fonts are used)|Cache not whitelisted by font provider|Contact font provider and ask them to whitelist [all caches](https://github.com/ampproject/amphtml/blob/master/spec/amp-cors-requests.md#cors-security-in-amp)|
|Assets (e.g. fonts and images) do not appear #1 (**HTTP origins only**)|Document uses protocol-relative URLs|Switch to absolute URLs (that is, `http://www.site.com/doc/amp`, not `//www.site.com/doc/amp`)|
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that the example should have an HTTPS protocol. And maybe use the domain https://www.example.com/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SchnWalter This item was specifically about HTTP origins, so http is correct. Probably example.com would be better but would really like to get this merged and so want to avoid making minor changes! (There's also another change I want to make to this doc soon (to mention https://cdn.ampproject.org/caches.json)--I can make the example.com change at the same time.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, yes, http, my bad.

Thanks for the great documentation!

@ericlindley-g
Copy link
Contributor

Thanks all!

@cramforce , @ithinkihaveacat , or @bpaduch — does one of you with merge access want to do the honors?

@cramforce cramforce merged commit c87d1f9 into ampproject:master Jun 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants