AMP Cache Guidelines
Provide guidelines to external parties for implementing their own AMP Caches.
In the AMP ecosystem, the platform that links to content may freely choose which AMP Cache (if any) to use. It is an inversion of the typical model where content delivery is the responsibility of the publisher.
This allows platforms to provide their users with predictable load performance and among other things allows them to ensure required security and privacy invariants during AMP’s pre-rendering phase.
AMP is an open ecosystem and the AMP Project actively encourages the development of more AMP Caches.
An AMP Cache only serves valid AMP input documents.
It participates in the AMP Project's validator release cycle.
It participates in the AMP JS library release cycle and makes every effort to serve the latest version. It does not allow sites to perform version locking.
It serves each site from a subdomain of the cache domain.
- See for example: the Google AMP Cache URL format.
Pledges to maintain URL space forever (even beyond the lifetime of the cache itself):
This can be achieved by donating the URL space to a trustworthy third party entity such as archive.org.
This means that, should a cache decide to no longer operate, URLs should redirect to the origin URL or be served by another cache.
Uses HTTPS serving only.
Serves a strong Content Security Policy (CSP) - a CSP defines a mechanism by which web developers can control the resources which a particular page can fetch or execute, as well as a number of security-relevant policy decisions.
Implements separately documented security rewrites on served content.
The CSP should be equivalent or stronger to what is being served on
Caches must update their CSP in a timely fashion (within 7 days) at the request of the AMP Project.
Supports a public Update Cache mechanism for document publishers to notify the AMP cache about new, updated or deleted documents:
- Equivalent to the Google AMP Update Cache API
Supports a public AMP Cache URL API:
- Equivalent to the Google AMP Cache URL API
Provides a faithful visual and UX reproduction of source document. E.g. changes in image resolution or compression rate may be acceptable if they provide strong benefits in terms of bandwidth usage and load time.
No obstruction of the contents, branding or attribution of the original AMP document.
No changes to ads, monetization, access (paywall monetization and similar), analytics, or similar.
Respects all resource deletions within a reasonable timeframe.
Uses a stale-while-revalidate caching model and reasonable min cache time (such as in the order of single digit minutes) is allowed. For example, as per Google AMP Cache updates, "[the cache] uses the origin's caching headers, such as Max-Age, as hints in deciding whether a particular document or resource is stale. When a user makes a request for something that is stale, that request causes a new copy to be fetched, so that the next user gets fresh content":
- The cache is allowed to serve stale content independent of HTTP caching headers. It must make reasonable efforts to keep the cache contents fresh and must revalidate content after serving stale responses.
- robots.txt: Content should be served from the Cache with either the same robot rules as the origin content or stricter rules. See https://cdn.ampproject.org/robots.txt for an example.
Guidelines: Optional Extensions
- Participation in AMP Ads For AMP Pages ("A4A") advertisement signing.
Guidelines: Accepted MIME types
MIME types for images
Accepted MIME types for images include all
image/ subtypes (e.g.
MIME types for fonts
Accepted MIME types for fonts include the following prefixes:
|Media type / subtype|
|text/plain (not recommended)|
Guidelines: Resource size limits
For resources (i.e., HTML, images, fonts) that are larger than 12 MB, you may not fetch the resource, and you may return a 404 error.
Guidelines: Adding a new cache to the AMP ecosystem
- Contact relevant publishers to make sure they update their CORS policies to include your origin.
- For further information please refer to the CORS Security in AMP Guidelines.
- Handle dynamically generated components:
- Publicly announce your cache so people know where to find your documentation.
- Examples of AMP Cache providers:
- Cloudflare AMP Cache
- Google AMP Cache
- Google AMP Cache Overview
- The Google AMP Cache is a proxy-based content delivery network for delivering all valid AMP documents.
- It fetches AMP HTML pages, caches them, and improves page performance automatically.
- When using the Google AMP Cache, the document, all JS files and all images load from the same origin, which is using HTTP 2.0 for maximum efficiency.
- The cache also comes with a built-in validation system which confirms that the page works, and that it doesn’t depend on external resources.
- The validation system runs a series of assertions confirming that the page’s markup meets the AMP HTML specification.
- Google AMP Cache FAQ
- Google AMP Cache updates
- Crawling Google AMP Cache URLs - How-to for search engines