amphtml: Google AMP cache error: unknown path prefix in url

Description

According to Google Search Console, my website (thrivous.com) has around 170 valid AMP pages. They all load fine and validate when accessed directly by appending #development=1 to the AMP URL.

However, when I attempt to access them in the Google AMP Cache, I get the following error message: “unknown path prefix in url.” Then the page redirects to the non-cached AMP page.

I have verified, using the Google AMP Cache URL API, that I’m using the correct Google AMP Cache URLs. They exist. And the API reports no errors.

Here’s an example:

{ “ampUrls”: [ { “originalUrl”: “https://thrivous.com/blogs/views/wheres-the-real-nzt-48-limitless-pill”, “ampUrl”: “https://thrivous.com/blogs/views/wheres-the-real-nzt-48-limitless-pill?view=amp”, “cdnAmpUrl”: “https://thrivous-com.cdn.ampproject.org/c/s/thrivous.com/blogs/views/wheres-the-real-nzt-48-limitless-pill?view=amp” } ] }

I can load the originalUrl and ampUrl without problems. When I attempt to load the cdnAmpUrl, I get the “unknown path prefix in url” in the browser console. And then the page redirects to the ampUrl.

This used to work fine. And, in fact, after I ran the Google AMP Cache URL API, it worked fine again for one or two page loads. But then it returned to giving the error message and redirecting. And running the API again doesn’t seem to fix it again.

I have attempted to present this issue to the Google support community. No one has been able to identify a solution. One person suggested that I post the issue here. That thread contains additional information, including screenshots:

https://support.google.com/webmasters/thread/115641650/how-do-i-fix-the-google-amp-cache-error-unknown-path-prefix-in-url?hl=en

How can I fix this permanently, so that the Google AMP Cache works without redirecting?

Reproduction Steps

  1. Verify that sample AMP page is validating:

https://thrivous.com/blogs/views/wheres-the-real-nzt-48-limitless-pill?view=amp#development=1

  1. Attempt to load sample AMP page in Google AMP cache:

https://thrivous-com.cdn.ampproject.org/c/s/thrivous.com/blogs/views/wheres-the-real-nzt-48-limitless-pill?view=amp

  1. Review web browser console. And note the following:

(a) The page redirected from the Google AMP cache to the original page.

(b) There’s an error message: “Unknown path prefix in url https://thrivous-com.cdn.ampproject.org/

Relevant Logs

amp.js:159 Powered by AMP ⚡ HTML – Version 2107030008001 https://thrivous.com/blogs/views/wheres-the-real-nzt-48-limitless-pill?view=amp#development=1
VM22:999 AMP validation successful.
VM22:999 Review our 'publishing checklist' to ensure successful AMP documentdistribution. See https://go.amp.dev/publishing-checklist
Navigated to https://thrivous-com.cdn.ampproject.org/c/s/thrivous.com/blogs/views/wheres-the-real-nzt-48-limitless-pill?view=amp
Navigated to https://thrivous.com/blogs/views/wheres-the-real-nzt-48-limitless-pill?view=amp
amp.js:159 Powered by AMP ⚡ HTML – Version 2107030008001 https://thrivous.com/blogs/views/wheres-the-real-nzt-48-limitless-pill?view=amp
error-reporting.js:208 Unknown path prefix in url  https://thrivous-com.cdn.ampproject.org/ ​​​
uf @ error-reporting.js:208
(anonymous) @ error-reporting.js:127
fb @ base.js:88
g.assert @ log.js:392
K @ log.js:794
df @ url.js:522
(anonymous) @ url-replacements-impl.js:165
Promise.then (async)
(anonymous) @ url-replacements-impl.js:160
(anonymous) @ promise.js:82
qa @ promise.js:81
Nk @ expander.js:359
Lk @ expander.js:336
d @ expander.js:210
Kk @ expander.js:295
Ik.expand @ expander.js:107
g.expandStringAsync @ url-replacements-impl.js:833
(anonymous) @ variables.js:500
Promise.then (async)
Mc @ variables.js:499
(anonymous) @ variables.js:435
(anonymous) @ index.js:187
sa @ index.js:177
Hc.expandTemplate @ variables.js:409
Re @ requests.js:207
Oe.send @ requests.js:137
(anonymous) @ amp-analytics.js:699
Promise.then (async)
wf @ amp-analytics.js:669
l.Sc @ amp-analytics.js:636
l.nc @ events.js:1707
(anonymous) @ visibility-manager.js:519
l.fire @ observable.js:78
(anonymous) @ visibility-model.js:76
Promise.then (async)
Nd @ visibility-model.js:75
de @ visibility-manager.js:413
l.listenRoot @ visibility-manager.js:286
l.add @ events.js:1519
c @ analytics-group.js:97
ne.addTrigger @ analytics-group.js:110
vf @ amp-analytics.js:453
(anonymous) @ amp-analytics.js:415
Promise.then (async)
l.jd @ amp-analytics.js:388
Promise.then (async)
of @ amp-analytics.js:262
l.layoutCallback @ amp-analytics.js:166
(anonymous) @ custom-element.js:1625
(anonymous) @ promise.js:82
qa @ promise.js:81
Qi.b.layoutCallback @ custom-element.js:1625
(anonymous) @ resource.js:897
am @ vsync-impl.js:468
g.wh @ vsync-impl.js:425
requestAnimationFrame (async)
Zl @ vsync-impl.js:392
g.Aa @ vsync-impl.js:386
g.run @ vsync-impl.js:185
g.runPromise @ vsync-impl.js:200
rj @ mutator-impl.js:206
g.mutateElement @ mutator-impl.js:153
ba @ amp-auto-lightbox.js:277
Z @ amp-auto-lightbox.js:320
(anonymous) @ amp-auto-lightbox.js:499
Promise.then (async)
(anonymous) @ amp-auto-lightbox.js:494
f @ amp-auto-lightbox.js:492
g.registerExtension @ extensions-impl.js:174
(anonymous) @ runtime.js:186
Promise.then (async)
(anonymous) @ runtime.js:182
Fi @ chunk.js:203
Bi.kf @ chunk.js:422
(anonymous) @ chunk.js:478
Promise.then (async)
Ii @ chunk.js:477
Bi.Aa @ chunk.js:496
Bi.runForStartup @ chunk.js:381
Ci @ chunk.js:72
om @ runtime.js:296
b @ runtime.js:197
c.AMP.push @ runtime.js:229
(anonymous) @ amp-auto-lightbox-0.1.js:1
base.js:83 Uncaught Error: Unknown path prefix in url https://thrivous-com.cdn.ampproject.org/​​​
    at fb (base.js:83)
    at yb.g.assert (log.js:392)
    at K (log.js:794)
    at df (url.js:522)
    at url-replacements-impl.js:165
fb @ base.js:83
g.assert @ log.js:392
K @ log.js:794
df @ url.js:522
(anonymous) @ url-replacements-impl.js:165
setTimeout (async)
za @ index.js:73
(anonymous) @ expander.js:378
Promise.catch (async)
Nk @ expander.js:377
Lk @ expander.js:336
d @ expander.js:210
Kk @ expander.js:295
Ik.expand @ expander.js:107
g.expandStringAsync @ url-replacements-impl.js:833
(anonymous) @ variables.js:500
Promise.then (async)
Mc @ variables.js:499
(anonymous) @ variables.js:435
(anonymous) @ index.js:187
sa @ index.js:177
Hc.expandTemplate @ variables.js:409
Re @ requests.js:207
Oe.send @ requests.js:137
(anonymous) @ amp-analytics.js:699
Promise.then (async)
wf @ amp-analytics.js:669
l.Sc @ amp-analytics.js:636
l.nc @ events.js:1707
(anonymous) @ visibility-manager.js:519
l.fire @ observable.js:78
(anonymous) @ visibility-model.js:76
Promise.then (async)
Nd @ visibility-model.js:75
de @ visibility-manager.js:413
l.listenRoot @ visibility-manager.js:286
l.add @ events.js:1519
c @ analytics-group.js:97
ne.addTrigger @ analytics-group.js:110
vf @ amp-analytics.js:453
(anonymous) @ amp-analytics.js:415
Promise.then (async)
l.jd @ amp-analytics.js:388
Promise.then (async)
of @ amp-analytics.js:262
l.layoutCallback @ amp-analytics.js:166
(anonymous) @ custom-element.js:1625
(anonymous) @ promise.js:82
qa @ promise.js:81
Qi.b.layoutCallback @ custom-element.js:1625
(anonymous) @ resource.js:897
am @ vsync-impl.js:468
g.wh @ vsync-impl.js:425
requestAnimationFrame (async)
Zl @ vsync-impl.js:392
g.Aa @ vsync-impl.js:386
g.run @ vsync-impl.js:185
g.runPromise @ vsync-impl.js:200
rj @ mutator-impl.js:206
g.mutateElement @ mutator-impl.js:153
ba @ amp-auto-lightbox.js:277
Z @ amp-auto-lightbox.js:320
(anonymous) @ amp-auto-lightbox.js:499
Promise.then (async)
(anonymous) @ amp-auto-lightbox.js:494
f @ amp-auto-lightbox.js:492
g.registerExtension @ extensions-impl.js:174
(anonymous) @ runtime.js:186
Promise.then (async)
(anonymous) @ runtime.js:182
Fi @ chunk.js:203
Bi.kf @ chunk.js:422
(anonymous) @ chunk.js:478
Promise.then (async)
Ii @ chunk.js:477
Bi.Aa @ chunk.js:496
Bi.runForStartup @ chunk.js:381
Ci @ chunk.js:72
om @ runtime.js:296
b @ runtime.js:197
c.AMP.push @ runtime.js:229
(anonymous) @ amp-auto-lightbox-0.1.js:1

Browser(s) Affected

Chrome, Safari

OS(s) Affected

No response

Device(s) Affected

No response

AMP Version Affected

No response

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 21 (10 by maintainers)

Most upvoted comments

@LincolnCannon The change is live now. It looks like https://thrivous-com.cdn.ampproject.org/c/s/thrivous.com/blogs/views/wheres-the-real-nzt-48-limitless-pill?view=amp is no longer redirecting, but please verify on your end and let me know if you continue to see issues.

It’s working! Thanks again, all, for your help – very much appreciated.

@LincolnCannon The change is live now. It looks like https://thrivous-com.cdn.ampproject.org/c/s/thrivous.com/blogs/views/wheres-the-real-nzt-48-limitless-pill?view=amp is no longer redirecting, but please verify on your end and let me know if you continue to see issues.

The change has been approved and submitted. However it is not in all production systems yet, but it may be worth trying and noting here if you still see the issue.

That’s a Google-internal link pointing to a pull request to update the code that fetches AMP documents from servers.

I sent http://cl/389064174 to mitigate this issue (hopefully). The Google AMP Cache sends requests in one of two different ways, and they have had different Accept ordering (since 2019). I’m making them consistent (with the version that results in a 200 here). Once approved, that’ll take a week or two to roll out.

It may still be worth investigating what caused that on your origin, since a different Accept header order should not cause a 404 or a 406, IIUC.

Sorry, correction. The 404 is not IP-dependent. I had failed to reproduce @jridgewell’s test case exactly. It depends on the ordering of the Accept header:

$ curl -si 'https://thrivous.com/blogs/views/wheres-the-real-nzt-48-limitless-pill?view=amp' | head -1
HTTP/2 200 
$ curl -si -H 'Accept: */*;q=0.8,application/signed-exchange;v=b3' 'https://thrivous.com/blogs/views/wheres-the-real-nzt-48-limitless-pill?view=amp' | head -1
HTTP/2 404 
$ curl -si -H 'Accept: application/signed-exchange;v=b3,*/*;q=0.8' 'https://thrivous.com/blogs/views/wheres-the-real-nzt-48-limitless-pill?view=amp' | head -1
HTTP/2 200 

or could this have begun happening when Google AMP cache began supporting signed exchanges?

I don’t believe we’ve made any changes to our Accept header since September 2019. If you’ve had recent articles that were properly displayed in AMP Cache, it’s likely it’s on the Shopify side.

@LincolnCannon note the headers that are included in the request @jridgewell is making. Those headers appear to be causing the server to issue a 404 response instead of the 200 when requested without them. The Google AMP Cache sends these headers to help servers respond with the “best” content to match what could be served to a user (e.g. signed exchanges).

The issue is that your server is returning 404 responses to the request the Google AMP Cache is making:

$ curl -I 'https://thrivous.com/blogs/views/wheres-the-real-nzt-48-limitless-pill?view=amp&x=2' \
  -H 'Accept: */*;q=0.8,application/signed-exchange;v=b3'

HTTP/1.1 404 Not Found
Date: Tue, 03 Aug 2021 21:13:22 GMT
Content-Type: text/plain; charset=utf-8
…