Skip to content

optimizer: Do not append rtv/{rtv}/ to ampUrlPrefix#517

Merged
sebastianbenz merged 3 commits intoampproject:masterfrom
mattwomple:patch-1
Oct 9, 2019
Merged

optimizer: Do not append rtv/{rtv}/ to ampUrlPrefix#517
sebastianbenz merged 3 commits intoampproject:masterfrom
mattwomple:patch-1

Conversation

@mattwomple
Copy link
Copy Markdown
Member

@mattwomple mattwomple commented Oct 4, 2019

BREAKING CHANGE

When both ampUrlPrefix and ampRuntimeVersion are specified, do not
append rtv/{rtv}/ to the prefix. If version information is expected in
the URL, it can be included in ampUrlPrefix.

@sebastianbenz
Copy link
Copy Markdown
Collaborator

Hm. This is confusing indeed. I'd prefer to not introduce a third parameter though. My suggestion would be: don't add the runtime version if a prefix is given. If someone wants to self-host a versioned runtime, they can append the version string to the prefix. Wdyt?

@mattwomple
Copy link
Copy Markdown
Member Author

Hm. This is confusing indeed. I'd prefer to not introduce a third parameter though. My suggestion would be: don't add the runtime version if a prefix is given. If someone wants to self-host a versioned runtime, they can append the version string to the prefix. Wdyt?

This would absolutely be my preference as well. It is a breaking change, though. Anyone who has optimizer implemented using ampUrlPrefix and ampRuntimeVersion with the expectation that the default pattern /rtv/{rtv} will automatically apply to their ampUrlPrefix will suddenly find their URLs broken when amp-toolbox updates in the future. Is it early enough in amp-toolbox's life that this is ok?

@sebastianbenz
Copy link
Copy Markdown
Collaborator

Yeah. I was thinking about the same. The transformer is marked as experimental since the 1.0 release so API changes are expected. I'm also not aware of anyone combining rtv + self-hosting. So I'd be OK with this change.

@googlebot
Copy link
Copy Markdown

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and then comment @googlebot I fixed it.. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added cla: no and removed cla: yes labels Oct 8, 2019
BREAKING CHANGE

When both ampUrlPrefix and ampRuntimeVersion are specified, do not
append rtv/{rtv}/ to the prefix. If version information is expected in
the URL, it can be included in ampUrlPrefix.
@googlebot
Copy link
Copy Markdown

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added cla: yes and removed cla: no labels Oct 8, 2019
@mattwomple mattwomple changed the title optimizer: Support suppression of RTV in rewrite URLs optimizer: Do not append rtv/{rtv}/ to ampUrlPrefix Oct 8, 2019
@mattwomple
Copy link
Copy Markdown
Member Author

Sorry for the force pushes. I accidentally committed changes using a different GitHub account.

@mattwomple
Copy link
Copy Markdown
Member Author

Tests have been updated. This is ready for review.

Copy link
Copy Markdown
Collaborator

@sebastianbenz sebastianbenz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One nit. Otherwise LGTM

@sebastianbenz sebastianbenz merged commit 9e7533c into ampproject:master Oct 9, 2019
@mattwomple mattwomple deleted the patch-1 branch October 9, 2019 19:47
@dreamofabear
Copy link
Copy Markdown

Why not ask callers to omit ampRuntimeVersion if they don't want RTV paths when using ampUrlPrefix?

@mattwomple
Copy link
Copy Markdown
Member Author

Why not ask callers to omit ampRuntimeVersion if they don't want RTV paths when using ampUrlPrefix?

Setting ampRuntimeVersion ensures you can maintain a correspondence between self-hosted runtime version and the version used during optimization. Consider this code:

if (version) {
v0CssUrl = appendRuntimeVersion(AMP_CACHE_HOST, version) + '/' + V0_CSS;
} else {
v0CssUrl = V0_CSS_URL;
version = await this.runtimeVersion_.currentVersion();
}
. If the self-hosted runtime is pushed on Monday, and then on Wednesday an AMP page is optimized, the inline CSS in the optimized AMP page will be associated with a different runtime version.

@dreamofabear
Copy link
Copy Markdown

Right, I was wondering specifically about the interaction between the two options.

  1. ampRuntimeVersion only
  2. ampUrlPrefix only
  3. ampRuntimeVersion and ampUrlPrefix

Instead of making (3) behave like (2), why not ask callers to just do (2)?

@mattwomple
Copy link
Copy Markdown
Member Author

Instead of making (3) behave like (2), why not ask callers to just do (2)?

How would optimizer know which runtime version should be used for performing its optimizations? It is not safe to assume "latest RTV available on cdn.ampproject.org". Specifying both ampRuntimeVersion and ampUrlPrefix informs optimizer what the URLs should look like to extensions and what version of boilerplate CSS should be included.

@dreamofabear
Copy link
Copy Markdown

Oh, I thought that cache transforms are not pegged to RTV. E.g. if they were, it would make AMP rollbacks very tricky.

/cc @ampproject/wg-caching

@sebastianbenz
Copy link
Copy Markdown
Collaborator

RTV is only relevant for v0.css. The AMP runtime will download the latest v0.css in case of a version mismatch.

@dreamofabear
Copy link
Copy Markdown

...it does? 😛

I know runtime does this for JS (v0 vs. extension RTV mismatch) but I don't think we do this for CSS which is bundled directly in the JS.

@sebastianbenz
Copy link
Copy Markdown
Collaborator

😀 download update. In any case, outdated v0.css shouldn't be an issue (at least that's what I was told that when I implemented the transformer).

mdmower added a commit to mdmower/amp-toolbox that referenced this pull request Jan 20, 2020
…ct#517)"

This reverts commit 9e7533c.

When self-hosting, follow the same URL structure in use by
cdn.ampproject.org, specifically:

- Non versioned URLs: https://example.com/runtime/
- Versioned URLs: https://example.com/runtime/rtv/{rtv}/
- Runtime metadata: https://example.com/rtv/metadata
mdmower added a commit to mdmower/amp-toolbox that referenced this pull request Jan 29, 2020
mdmower added a commit to mdmower/amp-toolbox that referenced this pull request Feb 2, 2020
sebastianbenz pushed a commit that referenced this pull request Feb 6, 2020
* Revert "optimizer: Make dynamic component URL rewrites optional (#518)"

This reverts commit 81e525d.

* Revert "optimizer: Do not append rtv/{rtv}/ to ampUrlPrefix (#517)"

This reverts commit 9e7533c.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants