ภาพรวม
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
เซิร์ฟเวอร์แคช AMP ของ Google จะเก็บสําเนาที่แคชของเนื้อหา AMP ที่ถูกต้องซึ่งเผยแพร่ไปยังเว็บ
แสดงเนื้อหาจากเซิร์ฟเวอร์แคช AMP ของ Google โดยตรง
เพื่อมอบประสบการณ์การใช้งานที่รวดเร็วให้แก่ผู้ใช้
หากต้องการใช้ประโยชน์จากเซิร์ฟเวอร์แคช AMP ของ Google คุณต้องเข้าถึง URL ของ AMP ได้โดยตรงจากแคชโดยใช้รูปแบบ URL แคชของ AMP
ทุกครั้งที่ผู้ใช้เข้าถึงเนื้อหา AMP จากแคช ระบบจะอัปเดตเนื้อหาโดยอัตโนมัติ และจะแสดงเวอร์ชันที่อัปเดตแล้วต่อผู้ใช้รายถัดไปเมื่อแคชเนื้อหาแล้ว
รูปแบบ URL แคชของ AMP ประกอบด้วยคอมโพเนนต์ต่อไปนี้
คอมโพเนนต์ |
คำอธิบาย |
ชื่อโดเมนย่อย |
โดเมนย่อยที่สร้างโดยเซิร์ฟเวอร์แคช AMP ของ Google จะอ่านได้ของมนุษย์เมื่อมีจํานวนอักขระสูงสุดและข้อกําหนดทางเทคนิคที่อนุญาต และคล้ายกับโดเมนของผู้เผยแพร่โฆษณาเอง เมื่อเป็นไปได้ เซิร์ฟเวอร์แคช AMP ของ Google จะสร้างโดเมนย่อยแต่ละรายการโดยดําเนินการดังนี้
- การแปลงโดเมนเอกสาร AMP จาก IDN (Punycode) เป็น UTF-8
- แทนที่ทุก "-" (ขีด) ด้วย "--"(ขีด 2 ขีด)
- แทนที่ทุก "." (จุด) ด้วย "-" (ขีด)
- กําลังแปลงกลับไปเป็น IDN (Punycode)
ตัวอย่างเช่น pub.com จะจับคู่กับ pub-com.cdn.ampproject.org
แต่หากมีข้อจํากัดทางเทคนิคทําให้โดเมนย่อยที่มนุษย์อ่านได้ ระบบจะใช้แฮชแบบทางเดียวแทน |
ประเภทเนื้อหา |
ประเภทเนื้อหามีดังนี้ 'c' สําหรับเอกสาร AMP HTML, 'i' สําหรับรูปภาพ หรือ 'r' สําหรับทรัพยากร เช่น แบบอักษร
เซิร์ฟเวอร์แคช AMP ของ Google แสดงข้อผิดพลาด 404 สําหรับทรัพยากรที่ไม่ตรงกับประเภทเนื้อหาเหล่านี้ (ดูข้อผิดพลาดหลัก) |
ไม่บังคับ 's' |
หากมี Google จะต้องดึงเนื้อหาจากต้นทางโดยใช้ TLS (HTTPS ที่ปลอดภัย) หากไม่มี 's' ก็จะดึงเนื้อหามาจากต้นทางโดยใช้ HTTP ธรรมดา |
URI |
URI ของเนื้อหาที่จะดึงข้อมูล URI ต้องไม่มีรูปแบบ นั่นคือ "http://" หรือ "https://" ไม่ใช่ |
การค้นหาชื่อโดเมนย่อย
โดยทั่วไปแล้ว ชื่อโดเมนย่อยสําหรับ URL เซิร์ฟเวอร์แคช AMP ของ Google จะเป็นการแปลง URL ต้นฉบับที่มนุษย์อ่านได้โดยใช้ขั้นตอนที่ระบุไว้ด้านบน อย่างไรก็ตาม เนื่องจากมีสถานการณ์ที่อาจไม่ใช่ข้อเท็จจริง วิธีที่ดีที่สุดในการดึงข้อมูล URL แคชของ Google สําหรับแอปพลิเคชันที่พร้อมใช้งานจริงคือการใช้ URL เซิร์ฟเวอร์แคช AMP ของ Google
ในสถานการณ์ที่ไม่ใช่การใช้งานจริง หากต้องการระบุชื่อโดเมนย่อยที่เซิร์ฟเวอร์แคช AMP ของ Google สร้างขึ้น ให้ลองใช้เครื่องมือแบบอินเทอร์แอกทีฟการใช้เซิร์ฟเวอร์แคช AMP ของ Google ใน amp.dev
ตัวอย่างการขอเอกสารโดยใช้ TLS
คําขอเอกสาร AMP HTML (ระบุด้วยคํานําหน้า /c
) ที่ดึงมาจาก https://example.com/amp_document.html
:
https://example-com.cdn.ampproject.org/c/s/example.com/amp_document.html
เนื่องจาก /s
ติดตามคํานําหน้า /c
ระบบจะดึงเอกสารจาก example.com โดยใช้ TLS
ตัวอย่างการขอรูปภาพโดยใช้ HTTP แบบธรรมดา
คําขอรูปภาพ (ระบุด้วยคํานําหน้า /i
) ที่ดึงมาจาก http://example.com/logo.png
:
https://example-com.cdn.ampproject.org/i/example.com/logo.png
และเนื่องจากไม่มี /s
ตามหลังคํานําหน้า /i
ทาง Google จะดึงรูปภาพจาก example.com โดยใช้ HTTP ธรรมดาแทน HTTP บน TLS
ตัวอย่างพารามิเตอร์การค้นหา
รูปแบบ URL แคชของ AMP อาจมีพารามิเตอร์ในสตริงการค้นหาได้เช่นกัน
ตัวอย่าง HTTPS ที่มีพารามิเตอร์มีดังนี้
https://example-com.cdn.ampproject.org/c/s/example.com/g?value=Hello%20World
การอัปเดตเซิร์ฟเวอร์แคช AMP ของ Google
เมื่อผู้ใช้ขอเอกสาร AMP จากแคช AMP ของ Google แคชจะขอการอัปเดตโดยอัตโนมัติเพื่อให้แสดงเนื้อหาใหม่สําหรับผู้ใช้คนถัดไปได้เมื่อแคชเนื้อหาแล้ว
เมื่อใช้โมเดลนี้ การอัปเดตเอกสาร AMP จะเผยแพร่โดยอัตโนมัติอย่างรวดเร็ว
ส่วนผู้ใช้จํานวนน้อยจะเห็นเวอร์ชันที่ไม่อัปเดตหลังจากการอัปเดต
แคชจะสอดคล้องกับโมเดล "stale-as-reverify"
โดยจะใช้ส่วนหัวการแคชของต้นทาง เช่น Max-Age
เป็นคําแนะนําในการตัดสินใจว่าเอกสารหรือทรัพยากรนั้นๆ ไม่มีการอัปเดตหรือไม่
เมื่อผู้ใช้ส่งคําขอที่ไม่มีการอัปเดต คําขอนั้นจะทําให้ระบบมีการคัดลอกรายการใหม่ เพื่อให้ผู้ใช้รายต่อไปได้รับเนื้อหาใหม่ๆ
หากต้องการจํากัดปริมาณโหลดที่สร้างขึ้นสําหรับเว็บไซต์ของผู้เผยแพร่โฆษณา
เซิร์ฟเวอร์แคช AMP ของ Google จะพิจารณาเอกสารใหม่เป็นเวลาอย่างน้อย 15 วินาที รวมถึงทรัพยากรใดก็ตามที่มีการอัปเดตอย่างน้อย 1 นาที
โปรดทราบว่าตัวเลขเหล่านี้อาจมีการเปลี่ยนแปลงในอนาคต เนื่องจากเราได้ปรับแต่งแคชเพื่อหาสมดุลระหว่างความใหม่กับการโหลดในเว็บไซต์ของผู้เผยแพร่โฆษณา
การเพิ่มประสิทธิภาพแคชและการแก้ไข
เซิร์ฟเวอร์แคช AMP ของ Google จะทําการเพิ่มประสิทธิภาพและแก้ไขต่างๆ เช่น
- ตรวจสอบความถูกต้องของเนื้อหาในรูปแบบ AMP โดยตรงตามเป้าหมายด้านประสิทธิภาพทั้งหมดของ AMP
- แคชรูปภาพและแบบอักษรเพิ่มเติมจากเอกสาร AMP
- จํากัดขนาดรูปภาพสูงสุดเพื่อป้องกันปัญหาหน่วยความจําของเบราว์เซอร์และการตอบสนองไม่ดี
- การแปลงแบบอื่นๆ เพื่อปรับปรุงประสิทธิภาพในการแสดงรูปภาพผ่านแท็ก
amp-img
เช่น
- การนําข้อมูลที่มองไม่เห็นหรือมองเห็นได้ยากออก เช่น ข้อมูลเมตาบางอย่าง
- การแปลงรูปภาพเป็นรูปแบบเล็กๆ ที่เหมาะกับอุปกรณ์เคลื่อนที่ เช่น การแปลงรูปภาพ GIF, PNG และ JPEG เป็น WebP ในเบราว์เซอร์ที่รองรับ WebP
- การเปลี่ยนรูปภาพให้มีคุณภาพต่ํากว่าหากคําขอมีส่วนหัว "บันทึกข้อมูล"
- การสร้างเวอร์ชันขนาดทางเลือกและการเพิ่มแอตทริบิวต์
srcset
เพื่อรองรับการนําส่งรูปภาพที่ปรับขนาดตามอุปกรณ์
- แสดงผลผ่านช่องทางที่ปลอดภัย (HTTPS) และใช้โปรโตคอลเว็บล่าสุด (SPDY, HTTP/2)
- ทําความสะอาดเอกสาร AMP เพื่อป้องกันการโจมตี XSS ตามแท็ก HTML ความคิดเห็น และอื่นๆ ที่ปิดอย่างไม่ถูกต้อง
ในการเปลี่ยนรูปแบบด้านบน เซิร์ฟเวอร์แคช AMP ของ Google จะไม่สนใจส่วนหัว "Cache-Control: no-Transform"
การทําความสะอาดข้อมูล HTML
เซิร์ฟเวอร์แคช AMP ของ Google จะเขียนเอกสารทั้งหมดใหม่เพื่อทําให้การแยกวิเคราะห์เป็นปกติ
ตัวอย่าง
- ความคิดเห็น HTML ทั้งหมดถูกตัดออก
- ชื่อแท็กและแอตทริบิวต์เป็นตัวพิมพ์เล็ก
- ค่าแอตทริบิวต์มีการอ้างอิงและ Escape อย่างสอดคล้องกัน
- แท็กทั้งหมดปิดอยู่ ยกเว้นองค์ประกอบที่ใช้เป็น HTML5
- ช่องว่างภายในแท็กถูกตัดออก
- ข้อความใช้ Escape
- อักขระที่ถูกเข้ารหัสจะทําให้มีความเรียบง่ายขึ้น โดยใช้อักขระเทียบเท่า UTF-8
- องค์ประกอบที่มีได้เฉพาะใน
body
จะย้ายไปยัง body
- ลิงก์ขาออกจะเป็นค่าสัมบูรณ์เพื่อให้ทํางานต่อไปได้เมื่อเอกสารแสดงจากต้นทางแคช AMP ของ Google แทนที่จะเป็นต้นทางของผู้เผยแพร่โฆษณา
เซิร์ฟเวอร์แคช AMP ของ Google เพิ่มแท็กคําแนะนําการดึงข้อมูลล่วงหน้าสําหรับเบราว์เซอร์ต่างๆ เพื่อช่วยในการโหลดทรัพยากรได้เร็วขึ้น
เช่น
<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 และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2023-08-30 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"]],["อัปเดตล่าสุด 2023-08-30 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```"]]