ampproject / ampproject/amphtml
[CACHE] Loading images from non-standard port does not work if page gets cached
- Dominant language
- JavaScript
- Stars
- 14.9k
- Forks
- 4.1k
- PR merge metrics
- No merged PRs in 30d
Description
### Description
If an image source points to a non-default port, the redirect built by the amp cache services points to non-existing host names and therefore no images are displayed if the page gets cached on google infrastructure.
### Reproduction Steps
1. Set an image source that does include a port number. Like
```
```
2. Get the page cached. This changes the Tag to ``
3. This `src` creates a request that contains a `location` header: `location: https://api-energate-de:81.cdn.ampproject.org/i/s/api.energate.de:81/assets/images/35509.jpg` - So it basically breaks the URI by including a colon into the host name and cannot redirect to that host.
* amp source page: https://amp.energate.de/217567
* Cached version with broken image: https://amp-energate-de.cdn.ampproject.org/c/s/amp.energate.de/217567
### Relevant Logs
```shell
From Console:
GET https://api-energate-de.cdn.ampproject.org/i/s/api.energate.de:81/assets/images/35509.jpg net::ERR_INVALID_REDIRECT
Full Response Headers for request of `https://api-energate-de.cdn.ampproject.org/i/s/api.energate.de:81/assets/images/35509.jpg` (line beginning with `#` included by me):
alt-svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"
cache-control: private
content-length: 289
content-type: text/html; charset=UTF-8
date: Fri, 26 Nov 2021 09:35:34 GMT
location: https://api-energate-de:81.cdn.ampproject.org/i/s/api.energate.de:81/assets/images/35509.jpg
# ^ fails
server: sffe
x-content-type-options: nosniff
x-xss-protection: 0
```
### Browser(s) Affected
_No response_
### OS(s) Affected
_No response_
### Device(s) Affected
_No response_
### AMP Version Affected
2111060251009
Contributor guide
Research direction
Start with the AMP cache image URL and redirect behavior described in the reproduction steps, using the supplied source and cached page URLs. Trace how a non-default port is incorporated into the redirect and verify that the cached image request produces a valid host and loads successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- cloud
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100