ampproject / ampproject/amphtml
Stop cache rewriting of URLs in style attributes of templates
- Dominant language
- JavaScript
- Stars
- 14.9k
- Forks
- 4.1k
- PR merge metrics
- No merged PRs in 30d
Description
### Background
Currently, URLs inside the `style` attribute of `` descendants are rewritten as AMP cache URLs (on pages served from AMP cache). For example:
```html
```
```html
```
This can cause bugs when the URLs have template variables, e.g. #19439. To avoid these bugs and [improve consistency with existing behavior](https://github.com/ampproject/amphtml/blob/master/spec/amp-cache-modifications.md#all-image-urls-are-rewritten-as-amp-cache-urls-except-those-in-amp-mustache-template), we're planning to disable cache rewriting of these URLs.
This is a potentially breaking change for pages served from AMP cache.
### Am I affected by this change?
If you're using relative URLs inside `style` attributes for descendants of `` elements, yes.
Otherwise, no.
### I'm affected. How do I fix it?
Change your relative URLs to be absolute. E.g. for the above example:
```html
```
### When will this change be made?
There's no timeline yet. First, we'll add code to detect these cases at runtime and output a user error. We'll update this issue with sufficient forward notice per the [deprecations policy](https://github.com/ampproject/amphtml/blob/master/spec/amp-versioning-policy.md#deprecations) if a formal deprecation is warranted.
Contributor guide
Assessment
This issue has not been assessed yet.