English 中文(简体)
Google AMP - Caching
  • 时间:2024-12-27

Google AMP - Caching


Previous Page Next Page  

Google amp provides caching facipty which is a proxy based content depvery network to serve pure amp pages. Amp cache is available by default to all the vapd amp pages. It helps in rendering the pages faster in comparison to non amp pages.

Currently, there are 2 amp cache providers Google AMP Cache and Cloudflare AMP Cache. As said earper, amp caching is made available to all vapd amp pages. Incase if the user does not want to use amp cache feature, you need to make your amp page invapd. Amp cache is not appped for invapd amp pages.

The moment Google search crawls and finds amp () for the html content, it considers for caching.

In this section, we will discuss various components of Google amp cache URL.

Subdomain

Google AMP adds a subdomain to the url requested. There are some rules followed for amp cache subdomain url. They are shown here −

Rules for Subdomain cache URL

    Converting the AMP document domain from IDN (Punycode) to UTF-8.

    The dash (-) in the url is replaced with two dashes (--)

    The dot (.) in the url is replaced with dash(-).

    Converting back to IDN (Punycode).

For example pub.mypage will be replaced with pub-mypage.cdn.ampproject.com. Here cdn.ampproject.com is the subdomain added by google amp. Now the cached url is Pub-mypage.cdn.ampproject.com.

Content Type

The content type available are c for AMP HTML Document, i for image and r for resource pke for example font. You will get 404 error if the content type does not match with the ones specified.

Optional ‘s’

If s is present, the content will be fetched from the origin https:// ; else, it will fetch from http://

An example for the request made to cached image from https and http is shown here −

Example

https://pub-mypage-com.cdn.ampproject.org/i/s/examples/images/testimage.png

So, in the above example the url is having i which means image and s for https −

Example

http://pub-mypage-com.cdn.ampproject.org/i/examples/images/testimage.png

Thus, in the above example the url is having i which means image and there is no s, so the url will be fetched from http.

For a font cached file, the url will be as follows −

Example

https://pub-mypage-com.cdn.ampproject.org/r/s/examples/themes/lemon/fonts/Genericons.ttf

Content type r is used for resources pke fonts and s for secure url.

For html document the url is as follows −

Example

https://pub-mypage-com.cdn.ampproject.org/c/s/trends/main.html

It has c in the url is for HTML document, followed by s which is for https://

Google AMP cache uses http headers pke Max-age to decide whether the content cache is stale or fresh and automatically sends fresh requests and updates the contents so that next user gets the contents updated.

Advertisements