ampproject / ampproject/amphtml

Self hosting: update validation rules

Open
#27,546 14 comments 0 reactions 2 assignees Assigned to @jridgewell View on GitHub
P2: Soon Stale WG: caching
Dominant language
JavaScript
Stars
14.9k
Forks
4.1k
PR merge metrics
No merged PRs in 30d

Description

See #25873 for context.

For supporting AMP runtime self-hosting the validation rules need to be adjusted:

```





...

```

This requires the following updates to the existing validation rules:

1. **meta name=runtime-host**

1. The runtime host declaration needs to be placed directly after the ``:
```


...
```

2. content needs to be a valid URL using the HTTPS protocol.

2. **meta name=amp-geo-api**

1. The amp-geo API endpoint declaration needs to be placed directly after the `meta name=runtime-host`:

```



...
```
**Note:** the order between `runtime-host` and `amp-geo-api` does not matter, I'm not sure if that could be easily expressed with the current validation rule semantics.

2. content needs to be a valid URL using the HTTPS protocol.

3. **`v0.js`, `custom-element` and `custom-template`**

All AMP script includes can be imported from a different host by replacing `https://cdn.ampproject.org` with a custom host URL `https://example.com/amp`. Everything after `https://cdn.ampproject.org` needs to stay the same.
```



```

The following rules apply:

1. `$HOST` must always be the same for all script imports.
2. `$HOST` must be a valid URL using the HTTPS protocol.
3. `$HOST` must be equal to ` `
4. Script paths for `v0.js`, `custom-element` and `custom-template` must stay the same:

```



```

**Open question:** should runtime self-hosting only be supported for transformed AMP? See also the discussion [here](https://github.com/ampproject/amphtml/issues/25873#issuecomment-583172339).

There are two valid view points:

1. **Yes:** self-hosting is mostly relevant for AMP first sites. AMP First sites should publish transformed AMP because of the greatly improved loading performance. Tying self-hosting to transformed AMP further emphasizes the importance of serving transformed AMP.
2. **No:** self-hosting is completely independent of transformed AMP and hence should not make it harder for publishers to self-host the runtime by requiring them to also serving optimized AMP.

//cc @Gregable @honeybadgerdontcare @mdmower @ampproject/wg-caching @ampproject/wg-runtime

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.