AMP Cache Update
-
Hi,
Has the feature of updating the cache been added to the plugin? If not, is there any possibility of adding it in near term?
-
I have already gone through this link – https://developers.google.com/amp/cache/update-cache but it’s a bit complicated for me to understand.
Thanks for reaching out. This feature has not yet been implementation. You can find out more and subscribe to the below GitHub issue for further updates on this:
https://github.com/ampproject/amp-wp/issues/598You may also find this GitHub issue useful, with users able to opt out of AMP cache for their content. This is also awaiting further updates from AMP upstream.
How do you change the max-age as mentioned in https://developers.google.com/amp/cache/update-cache
Is there any way to test, if a URL is being served from AMP Cache or not?
For example, this is an AMP page – https://www.whats-on-netflix.com/news/harry-potter-movies-netflix-2020/amp/, I have validated it on AMP Test.
When I check it’s header, it can’t be identified if it’s being served from AMP Cache or not –
{‘Date’: ‘Wed, 20 Jan 2021 03:20:36 GMT’, ‘Content-Type’: ‘text/html; charset=UTF-8’, ‘Transfer-Encoding’: ‘chunked’, ‘Connection’: ‘keep-alive’, ‘Set-Cookie’: ‘__cfduid=d7e443a8d90cded562959a8767b6aab931611112836; expires=Fri, 19-Feb-21 03:20:36 GMT; path=/; domain=.whats-on-netflix.com; HttpOnly; SameSite=Lax; Secure’, ‘Last-Modified’: ‘Tue, 19 Jan 2021 21:12:03 GMT’, ‘Cache-Control’: ‘public, max-age=7776000’, ‘Expires’: ‘Tue, 20 Apr 2021 03:20:36 GMT’, ‘Vary’: ‘Accept-Encoding,User-Agent,Accept-Encoding’, ‘CF-Cache-Status’: ‘DYNAMIC’, ‘cf-request-id’: ’07bf6804390000dca13096e000000001′, ‘Expect-CT’: ‘max-age=604800, report-uri=”https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct”‘, ‘Report-To’: ‘{“endpoints”:[{“url”:”https:\\/\\/a.nel.cloudflare.com\\/report?s=EBLDIer3oL87%2FzpNM0LSs0%2Fv7p3IdQLyxy%2Fn19V%2B1loHbRRpKrY33jbQPojeGf%2BVE84VzHXtbL%2FseQ3Y9YpX8X4j2qpljJQgz6mVTv%2BeO05BmgVP7xBLEFo%3D”}],”group”:”cf-nel”,”max_age”:604800}’, ‘NEL’: ‘{“report_to”:”cf-nel”,”max_age”:604800}’, ‘Strict-Transport-Security’: ‘max-age=0; preload’, ‘X-Content-Type-Options’: ‘nosniff’, ‘Server’: ‘cloudflare’, ‘CF-RAY’: ‘6145a919fbd4dca1-MAA’, ‘Content-Encoding’: ‘gzip’}This is a non-AMP page – https://www.whats-on-netflix.com/whats-new/ and the Header response is the same –
{‘Date’: ‘Wed, 20 Jan 2021 03:22:58 GMT’, ‘Content-Type’: ‘text/html; charset=UTF-8’, ‘Transfer-Encoding’: ‘chunked’, ‘Connection’: ‘keep-alive’, ‘Set-Cookie’: ‘__cfduid=df0951d84755de428221422eb1ac491631611112978; expires=Fri, 19-Feb-21 03:22:58 GMT; path=/; domain=.whats-on-netflix.com; HttpOnly; SameSite=Lax; Secure’, ‘Last-Modified’: ‘Tue, 19 Jan 2021 16:37:34 GMT’, ‘Cache-Control’: ‘public, max-age=7776000’, ‘Expires’: ‘Tue, 20 Apr 2021 03:22:58 GMT’, ‘Vary’: ‘Accept-Encoding,User-Agent,Accept-Encoding’, ‘CF-Cache-Status’: ‘DYNAMIC’, ‘cf-request-id’: ’07bf6a2fff0000df538da69000000001′, ‘Expect-CT’: ‘max-age=604800, report-uri=”https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct”‘, ‘Report-To’: ‘{“endpoints”:[{“url”:”https:\\/\\/a.nel.cloudflare.com\\/report?s=QKFl%2FTQTZvtieurNFr6Krrkc%2BJXUFNPUiMc7ikJQGvUUFgpj%2FQ6SBOXZSiksAcRCXmowGPDJyeLNBDEw%2F4eBOo2pnWYHoF0scayNWXHEHpU0xOi%2Bv1CB0So%3D”}],”group”:”cf-nel”,”max_age”:604800}’, ‘NEL’: ‘{“max_age”:604800,”report_to”:”cf-nel”}’, ‘Strict-Transport-Security’: ‘max-age=0; preload’, ‘X-Content-Type-Options’: ‘nosniff’, ‘Server’: ‘cloudflare’, ‘CF-RAY’: ‘6145ac933f36df53-BOM’, ‘Content-Encoding’: ‘gzip’}
If the URL is valid AMP, then it is eligible to be served from an AMP Cache.
Here is the URL to the Google AMP Cache: https://www-whats–on–netflix-com.cdn.ampproject.org/c/s/www.whats-on-netflix.com/news/harry-potter-movies-netflix-2020/amp/
But it can’t be tested using the response header string? I mean the original URL not ampproject one.
-
This reply was modified 5 years, 2 months ago by
FlixWatch Support.
As for setting the max-age, here is some PHP code you can use in a custom plugin:
add_filter( 'wp_headers', function ( $headers ) { if ( ! isset( $headers['Cache-Control'] ) && ! is_user_logged_in() ) { $headers['Cache-Control'] = 'public, max-age=604800'; } return $headers; } );That would set the max-age to 1 week.
But it can’t be tested using the response header string? I mean the original URL not ampproject one.
I don’t understand.
I mean, can it be tested by using the https://www.whats-on-netflix.com/news/harry-potter-movies-netflix-2020/amp/ directly if its cached or not. Or do I have to check https://www-whats–on–netflix-com.cdn.ampproject.org/c/s/www.whats-on-netflix.com/news/harry-potter-movies-netflix-2020/amp/ the status 200/date here to see if it has been cached or not.
If your AMP page has been indexed by Google Search, then you should assume it is cached by the Google AMP Cache.
I mean, can it be tested by using the https://www.whats-on-netflix.com/news/harry-potter-movies-netflix-2020/amp/ directly if its cached or not. Or do I have to check https://www-whats–on–netflix-com.cdn.ampproject.org/c/s/www.whats-on-netflix.com/news/harry-potter-movies-netflix-2020/amp/ the status 200/date here to see if it has been cached or not.
You can’t check the AMP page on your own server if it is in an AMP Cache, no. There are multiple AMP Caches, including the Google one and the Bing one.
In fact, the AMP Cache works as a reverse proxy, so the moment that you access an AMP page via the cache, then it will at that point be added to the cache, as far as I know.
So I can go to another URL on your site that has never before been seen by the AMP Cache, like https://www-whats–on–netflix-com.cdn.ampproject.org/c/s/www.whats-on-netflix.com/news/harry-potter-movies-netflix-2020/amp/?unique-never-before-seen-string and it will then be fetched and cache on demand.
Got it. Thanks.
-
This reply was modified 5 years, 2 months ago by
The topic ‘AMP Cache Update’ is closed to new replies.