Site icon Dhanendran's Blog

How to update AMP cache on Google?

So you are using AMP for your website, that’s great. AMP is one of the best way to increase the traffic to your site.

Often confused how AMP is cached in Google and when the content is updated in cache?

AMP Caching

AMP is using ‘stale-while-revalidate’ model.

Indicates that the client is willing to accept a stale response while asynchronously checking in the background for a fresh one. The seconds value indicates for how long the client is willing to accept a stale response.

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control

Google will try to check the origin site for the new content when a user views the page. If content is changed in the origin server, then Google will update the content in cache and serves it to the next user.

Update AMP Cache

Want to update the AMP cache immediately when the content is updated in the origin? Yes, that’s possible with the Google’s update-cache URL. Google provides a special URL to clear any AMP content on the cache. When you Google’d about this you should have come across this page.

Get AMP Cached URL

Finding hard to get the Cached AMP URL? Don’t worry ampbyexample.com has a tool to make your job easy.

Paste your post URL on the ampbyexample.com URL conversion box and hit convert. It will give the Cache version of your post.

 

RSA Keys

All AMP cache clear request to Google must to signed with the proper RSA keys to prove the authenticity of your content on Google cache. So generate the private and public keys with the help of OpenSSL‘s command line tools.

 

Guidelines

You must follow the update-cache guidelines:

AMP Cache Clear

Construct the cache clear URL in the specified format.

https://example-com.<cache.updateCacheApiDomainSuffix>/update-cache/c/s/example.com/article?amp_action=flush&amp_ts=<ts_val>&amp_url_signature=<sig_val>

Hit this URL every time you want to clear the post cache from Google CDN like on every post save event.

 

That’s it. Cache will be cleared from Google CDN and fresh content will be shown to the next user who request for the content from Google.

Exit mobile version