ampproject / amp-sw

A drop in service worker library to help your AMP pages gain network resiliency in 1 line

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Caching amp-list responses (particularly for when offline)

alankent opened this issue · comments

The SW caches a number of URL types (images, documents, etc). One that appears to be missing is <amp-list> API calls. Consider a category page on an ecomm site. It might fetch a default set of products to show on the category page, but if there is a network problem, no cache will be used to display the old set of products.

I think can assume the server will return HTTP headers saying how long the response can be cached for (including '0' for "do not cache this resource"). If a request is made when there is no network, it would be good to:

(1) Display the old page (better than displaying nothing).

(2) Indicate the network is temporarily offline / unreliable.

Not as important as the other caches, but I thought I would mention it / ask why it is not supported.

you can for sure use assetCachingOptions to point to the APIs as well...
This will allow you to

  • cache the page
  • cache the API

But one thing thats missing is configurability of the expiration of these cache.