Need to send cache-control max age to Google AMP Cache... how?

Hi all,

The goal - have the Google AMP Cache refresh my AMP pages quickly.


I use a CF worker script to change certain content (ad codes) on my pages as they are fetched by the client.

Works great on my regular pages, but on my AMP pages Google caches the page and provides stale results without the ad codes changing for hours sometimes.

Is there a way to use CF to set a max-age of, say, 30 seconds, on the AMP pages cached by Google AMP Cache?

I know… they refresh in the background while serving stale content, so it’s not perfect, but it’s the best potential solution I’ve been able to come up with.

CF does not need to (but it can, if required) refresh its cache of my AMP pages that often, the worker script takes care of that, but I need to set the cache control on outgoing pages.

Maybe a page rule, or is there a way to add something to my worker script to do this? I have a ‘pro’ CF account.

My wish - I could set Google to use CF AMP Cache instead, and run a worker on it, or that Google AMP Cache had workers that could be set up like CF’s :slight_smile:




It’s counter intuitive, but you need to never cache anything in an AMP site. Disable caching.