ampproject / amphtml

The AMP web component framework.
https://amp.dev
Apache License 2.0
14.89k stars 3.89k forks source link

Support for off cache AMP path #29296

Closed nainar closed 2 years ago

nainar commented 4 years ago

Introduction

Allow for developers to voluntarily opt out of a valid AMP page being in the cache. This will make personalization and cookie management much easier.

Motivation

AMP helps developers create performant sites by enabling the following:

In an effort to create pages that load instantaneously we push developers to create valid AMP pages that are served from the cache. Even as projects like Bento and launch, the end goal each developer is being forced to achieve is still to be served from the cache.

However, currently developers face a multitude of problems when their pages are served from the AMP cache:

Solution Issues
Implement SxG SxG is only available on Chrome
Create invalid AMP pages Lose out on validation of AMP pages. Developers want the productivity of creating AMP pages and aren't doing anything not allowed by AMP's principles. However, they are being forced to create dirty or Bento AMP pages because they don't want the page to served from cache.
[FUTURE] Create Bento AMP pages. Lose out on validation of AMP pages. Developers want the productivity of creating AMP pages and aren't doing anything not allowed by AMP's principles. However, they are being forced to create dirty or Bento AMP pages because they don't want the page to served from cache.

Proposals

Any proposal should have the following:

Opt out transformed AMP pages from AMP Caches

Pages transformed by the AMP Toolbox Optimizer are the closest we can get to mimicking Cache like performance on origin. Allow developers to opt out transformed AMP pages out of the cache by marking the page as such:

Valid and cached AMP

Markup: <html amp> | <html ⚡> How does this work: AMP Pages are ingested as normal. Result: This page is intended to be served from the cache

Valid and non cached AMP

Markup: <html amp="no-caching"> | <html ⚡no-cache> How does this work:

Valid AMP that is cached if SxG is supported

Markup: <html amp="only-cache-if-sxg"> How does this work:

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

Gregable commented 2 years ago

Considering the discussion in the past, I'm going to explicitly close this with explanation rather than have stale bot do so.

The proposal for <html ⚡no-cache> has always worked, by nature of this making the page invalid with a single error. The only difference from the proposal is "This page should pass the validator". This is a semantic difference, but since the purpose of Pass/Fail of the validator is one of the criteria for determining inclusion in the cache, it seems sufficient.

The specific <html amp="only-cache-if-sxg"> is a more functional feature request. Since this bug was filed, however, Google search now provides the option of signed exchanges without needing AMP. Publishers could choose to serve an invalid-amp, valid-signed-exchange to achieve the same thing. In general, this is more flexible anyway, since it affords the page the ability to use arbitrary JavaScript or violate any other provision of the AMP spec, if desired.