概要
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
Google AMP Cache は、ウェブに公開されている有効な AMP コンテンツのキャッシュ コピーを提供します。Google AMP キャッシュからコンテンツを直接提供することで、高速なユーザー エクスペリエンスを実現します。
Google AMP キャッシュを利用するには、AMP キャッシュの URL フォーマットを使用して、キャッシュから AMP URL に直接アクセスする必要があります。ユーザーがキャッシュから AMP コンテンツにアクセスするたびにコンテンツが自動的に更新されます。また、コンテンツがキャッシュされると、次にアクセスしたユーザーには更新版のコンテンツが提供されます。
AMP キャッシュの URL フォーマットは次のコンポーネントで構成されています。
コンポーネント |
説明 |
サブドメイン名 |
Google AMP キャッシュで作成されたサブドメインは、文字数制限と技術仕様で許容される場合には人が読める形式になり、サイト運営者のドメインによく似たものになります。可能な場合、Google AMP キャッシュでは次の手順で各サブドメインが作成されます。
- AMP ドキュメントのドメインを IDN(Punycode)から UTF-8 に変換する。
- すべての「-」(ダッシュ)を「--」(2 個のダッシュ)に置き換える。
- すべての「.」(ドット)を「-」(ダッシュ)に置き換える。
- AMP ドキュメントのドメインを IDN(Punycode)に戻す。
たとえば、pub.com は pub-com.cdn.ampproject.org にマッピングされます。技術的な制限によってサブドメインを人が読める形式にできない場合は、代わりに一方向ハッシュが使用されます。 |
コンテンツ タイプ |
コンテンツ タイプには、「c」(AMP HTML ドキュメント)、「i」(画像)、「r」(フォントなどのリソース)のいずれかを指定します。Google AMP キャッシュは、これらのコンテンツ タイプが指定されていないリソースに対して 404 エラーを返します(主要なエラーを参照)。 |
オプションの「s」 |
指定されている場合、Google が TLS(セキュアな HTTPS)を使用して元のページからコンテンツを取得する必要があります。「s」が指定されていない場合、通常の HTTP を使用して元のページからコンテンツが取得されます。 |
URI |
取得されるコンテンツの URI。この URI にはスキーム(「http://」や「https://」など)を含めることができません。 |
サブドメイン名の確認
通常、Google AMP キャッシュ URL のサブドメイン名は、上記の手順で元の URL を人が読める形式に変換したものになります。ただし、このようにならない場合もあるため、製品版アプリケーションの Google AMP キャッシュ URL を取得する場合は、Google AMP Cache URL API を使用することをおすすめします。
製品版以外の場合、Google AMP Cache によって生成されたサブドメイン名を確認するには、amp.dev にある Google AMP Cache を使用するのインタラクティブ ツールを試してみてください。
TLS を使用したドキュメントのリクエストの例
https://example.com/amp_document.html
から取得した AMP HTML ドキュメント(/c
プレフィックスで指定)のリクエスト:
https://example-com.cdn.ampproject.org/c/s/example.com/amp_document.html
/s
が /c
プレフィックスの後にあるため、ドキュメントは TLS を使用して example.com から取得されます。
通常の HTTP を使用した画像のリクエストの例
http://example.com/logo.png
から取得した画像(/i
プレフィックスで指定)のリクエスト:
https://example-com.cdn.ampproject.org/i/example.com/logo.png
/s
が /i
プレフィックスの後にないため、画像は HTTP over TLS ではなく通常の HTTP を使用して example.com から取得されます。
クエリ パラメータの例
AMP キャッシュの URL フォーマットには、クエリ文字列のパラメータを含めることもできます。次は、パラメータを含む HTTPS の例です。https://example-com.cdn.ampproject.org/c/s/example.com/g?value=Hello%20World
Google AMP キャッシュの更新
ユーザーが Google AMP キャッシュに対して AMP ドキュメントをリクエストすると、次にリクエストするユーザーに最新のコンテンツを提供できるようにするために、コンテンツがキャッシュされた後に Google AMP キャッシュから更新が自動的にリクエストされます。このモデルでは、AMP ドキュメントの更新が自動的にすばやく反映されるため、ドキュメントの更新後に更新前のバージョンが表示されることはほとんどありません。
キャッシュは、「stale-while-revalidate」モデルに従います。このモデルでは、特定のドキュメントやリソースが最新でないかどうかを判断する際のヒントとして、元のキャッシュ ヘッダー(Max-Age
など)を使用します。ユーザーが最新でないものに対するリクエストを行うと、そのリクエストによって新しいコピーが取得され、次にリクエストするユーザーが最新のコンテンツを取得できるようになります。
Google AMP キャッシュでは、サイト運営者のサイトに生じる負荷の量を制限するために、ドキュメントは 15 秒以上、リソースは 1 分以上の間、最新と見なされます。Google では、キャッシュの調整によってサイト運営者のサイトの鮮度と負荷の最適なバランスを保っています。そのため、この時間は将来変更される可能性があります。
キャッシュの最適化と変更
Google AMP キャッシュでは、次のような最適化と変更を行います。
- コンテンツが本当に AMP 形式になっており、AMP のパフォーマンス目標をすべて達成しているかどうかを検証します。
- AMP ドキュメントに加え、画像やフォントもキャッシュします。
- 画像の最大サイズを制限し、ブラウザのメモリに関する問題や応答性の低下を防止します。
amp-img
タグを使用した各種変更により、画像の配信効率が向上します。たとえば、次のような変更を行います。
- 表示されないデータや表示しづらいデータ(特定のメタデータなど)の削除。
- 小さな画像形式からよりモバイル フレンドリーな画像形式への画像の変換(WebP 対応のブラウザでの GIF、PNG、JPEG 形式から WebP 形式への画像の変換など)。
- リクエストに Save-Data ヘッダーが含まれている場合の低画質の画像への変換。
- サイズ調整されたバージョンの生成と、それに応じてサイズ調整された画像の配信をサポートするための
srcset
属性の追加。
- セキュアなチャネル(HTTPS)で配信し、最新のウェブ プロトコル(SPDY、HTTP/2)を使用します。
- 誤って閉じられた HTML タグやコメントなどに基づく XSS 攻撃を防止するために、AMP ドキュメントをサニタイズします。
上記の変更を行うにあたり、Google AMP キャッシュでは「Cache-Control: no-transform」ヘッダーを無視します。
HTML のサニタイズ
Google AMP キャッシュでは、解析を標準化するためにすべてのドキュメントが書き換えられます。許可されない業務形態の例は次のとおりです。
- すべての HTML コメントが削除されます。
- タグ名と属性名が小文字に変換されます。
- 属性値が常に引用符で囲まれ、エスケープされます。
- HTML5 の空要素を除くすべてのタグが閉じられます。
- タグ内の空白は削除されます。
- テキストがエスケープされます。
- エンコードされたテキスト文字が、UTF-8 の同等の文字を使用して簡略化されます。
body
内でのみ指定できる要素は body
内に移動されます。
- ドキュメントがサイト運営者からではなく Google AMP キャッシュから提供される場合でも外部へのリンクを引き続き使用できるよう、外部へのリンクが絶対リンクに設定されます。
Google AMP キャッシュでは、各種のプリフェッチ ヒントタグをブラウザ用に追加することにより、リソースの早期読み込みをサポートしています。たとえば、<link href='https://fonts.googleapis.com/css?family=Lato' rel='stylesheet’>
は次のように変更されます。
<link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet">
<link href="https://fonts.gstatic.com" rel="dns-prefetch preconnect">
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-08-04 UTC。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-08-04 UTC。"],[[["\u003cp\u003eGoogle AMP Cache delivers cached copies of valid AMP content for a faster user experience.\u003c/p\u003e\n"],["\u003cp\u003eUtilize the AMP Cache URL format to access content directly from the cache, ensuring automatic updates with each user access.\u003c/p\u003e\n"],["\u003cp\u003eThe Google AMP Cache optimizes and modifies content, including image transformations, security enhancements, and HTML sanitization, to improve delivery and performance.\u003c/p\u003e\n"],["\u003cp\u003eThe cache employs a "stale-while-revalidate" model, using origin caching headers and automatic updates to balance content freshness with publisher site load.\u003c/p\u003e\n"]]],["The Google AMP Cache stores and serves cached AMP content for fast user experiences. Accessing content via the AMP Cache URL format triggers automatic updates. The format includes a subdomain, content type (`c`, `i`, or `r`), optional `s` for TLS, and the content's URI. Content is considered fresh for at least 15 seconds (documents) or 1 minute (resources) before being revalidated. The cache optimizes content, such as images and documents, by validating AMP format, applying various transformations, and sanitizing HTML, for efficient and secure delivery.\n"],null,["# Overview\n\nThe Google AMP Cache serves cached copies\nof valid AMP content published to the web.\nServe content directly from the Google AMP Cache\nto provide a fast user experience.\n\n\nTo take advantage of the Google AMP Cache,\nan AMP URL must be accessed directly from the cache\nusing the AMP Cache URL format.\nEach time a user accesses AMP content from the cache,\nthe content is automatically updated,\nand the updated version is served to the next user once the content has been cached.\n\nAMP Cache URL format\n--------------------\n\n\nThe AMP Cache URL format consists of the following components:\n\n| Component | Description |\n|----------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Subdomain name | Subdomains created by the Google AMP Cache will be human-readable when character limits and technical specs allow, and will closely resemble the publisher's own domain. When possible, the Google AMP Cache will create each subdomain by: 1. Converting the AMP document domain from IDN (Punycode) to UTF-8. 2. Replacing every \"-\" (dash) with \"--\"(2 dashes). 3. Replacing every \".\" (dot) with a \"-\" (dash). 4. Converting back to IDN (Punycode). For example, `pub.com` will map to `pub-com.cdn.ampproject.org`. Where technical limitations prevent a human readable subdomain, a one-way hash will be used instead. |\n| Content type | The content type is one of the following: 'c' for an AMP HTML document, 'i' for an image, or 'r' for a resource such as a font. The Google AMP Cache returns a 404 error for resources that do not match these content types (see the [core error](/amp/cache/reference/errors/core_errors#NOT_FOUND)). |\n| Optional 's' | If present, requires that Google fetch the content from the origin using TLS (secure HTTPS). If the 's' is not present, then content gets fetched from the origin using plain HTTP. |\n| URI | URI of the content to be fetched. The URI cannot contain a scheme; that is, no \\`http://\\` or \\`https://\\`. |\n\n| **Note:** Use the [AMP URL API](/amp/cache/reference/acceleratedmobilepageurl/rest/v1/ampUrls/batchGet), to match URLs to corresponding AMP URLs and serve the AMP versions instead (see [Link to AMP Content](/amp/cache/use-amp-url)).\n\n### Finding the subdomain name\n\nTypically, the subdomain name for a Google AMP Cache URL will be a human-readable conversion of\nthe original URL using the steps outlined above. However, because there are circumstances where\nthis may not be true, the best way to retrieve Google AMP Cache URLs for production-ready\napplications is to use the [Google AMP Cache URL API](/amp/cache/use-amp-url).\n\nFor non-production situations, to determine what subdomain name the Google AMP Cache generates,\ntry out the [Using the Google AMP Cache](https://amp.dev/documentation/examples/guides/using_the_google_amp_cache/)\ninteractive tool on [amp.dev](https://amp.dev/documentation/examples/guides/using_the_google_amp_cache/).\n\n### Example requesting document using TLS\n\nRequest for an AMP HTML document (specified with the `/c` prefix)\nfetched from `https://example.com/amp_document.html`: \n\n```\nhttps://example-com.cdn.ampproject.org/c/s/example.com/amp_document.html\n```\n\nBecause `/s` follows the `/c` prefix,\nthe document will be fetched from example.com using TLS.\n\n### Example requesting image using plain HTTP\n\nRequest for an image (specified with the `/i` prefix)\nfetched from `http://example.com/logo.png`: \n\n```\nhttps://example-com.cdn.ampproject.org/i/example.com/logo.png\n```\n\nBecause there's no `/s` following the `/i` prefix,\nGoogle fetches the image from example.com using plain HTTP,\nnot HTTP over TLS.\n\n### Query parameter example\n\nThe AMP Cache URL format can also include parameters in the query string.\nThe following is an HTTPS example with parameters:\n`https://example-com.cdn.ampproject.org/c/s/example.com/g?value=Hello%20World`\n\nGoogle AMP Cache updates\n------------------------\n\nWhen a user requests an AMP document from the Google AMP Cache,\nthe cache automatically requests updates in order to be able\nto serve fresh content for the next user once the content has been cached.\nWith this model, updates to AMP documents propagate automatically and quickly;\nfew users will see the non-updated version after your update.\n\n\nThe cache follows a \"stale-while-revalidate\" model.\nIt uses the origin's caching headers, such as `Max-Age`,\nas hints in deciding whether a particular document or resource is stale.\nWhen a user makes a request for something that is stale,\nthat request causes a new copy to be fetched, so that the next user gets fresh content.\n\n\nTo limit the amount of load it generates for publisher sites,\nthe Google AMP Cache considers any document fresh for at least 15 seconds,\nand any resource fresh for at least 1 minute.\nNote that those numbers may change in the future,\nas we tune the cache for optimum balance between freshness and load on publisher sites.\n\nCache optimizations and modifications\n-------------------------------------\n\nThe Google AMP Cache performs optimizations and modifications,\nsuch as the following:\n\n- Validates content is truly in AMP format, meeting all AMP performance goals.\n- Caches images and fonts in addition to AMP documents.\n- Limits maximum image dimensions to prevent browser memory issues and poor responsiveness.\n- Various transformations to improve the delivery efficiency of images via the `amp-img` tag, such as:\n - Removal of data that is invisible or difficult to see, such as certain metadata.\n - Conversion of images to smaller and mobile-friendlier image formats, such as converting GIF, PNG, and JPEG format images to WebP in browsers that support WebP.\n - Transformation of the image to a lower quality if the request includes the Save-Data header.\n - Generation of alternatively sized versions and adding `srcset` attributes to support delivery of responsively sized images.\n- Serves over a secure channel (HTTPS) and uses the latest web protocols (SPDY, HTTP/2).\n- Sanitizes AMP documents to prevent XSS attacks based on incorrectly closed HTML tags, comments, and more.\n\n\nIn making the above transformations,\nthe Google AMP Cache disregards the \"Cache-Control: no-transform\" header.\n\nHTML sanitization\n-----------------\n\n\nThe Google AMP Cache rewrites all documents to normalize parsing.\nExamples include:\n\n- All HTML comments are stripped.\n- Tag and attribute names are lowercased.\n- Attribute values are consistently quoted and escaped.\n- All tags are closed, except for HTML5 void elements.\n- Whitespace inside tags is stripped.\n- Text is escaped.\n- Encoded text characters are simplified, using UTF-8 equivalent characters.\n- Elements that can only be in the `body` get moved into the `body`.\n- Outbound links are made absolute so that they continue to work when the document is served from the Google AMP Cache origin instead of the publisher origin.\n\nInsert prefetch tags\n--------------------\n\nThe Google AMP Cache adds various prefetch hint tags for browsers\nto assist in loading resources earlier.\nFor example,\n`\u003clink href='https://fonts.googleapis.com/css?family=Lato' rel='stylesheet'\u003e`\nchanges to: \n\n```text\n\u003clink href=\"https://fonts.googleapis.com/css?family=Lato\" rel=\"stylesheet\"\u003e\n\u003clink href=\"https://fonts.gstatic.com\" rel=\"dns-prefetch preconnect\"\u003e\n```"]]