You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Cloudflare AMP Optimizer is a Cloudflare Worker that will automatically optimize and cache any AMP pages & content from your origin so everyone can get the benefit of AMP optimized pages, not just users going through the AMP Cache.
Under the hood, cloudflare-amp-optimizer utilizes the AMP Optimizer library. If you'd like to pass through configuration options to the underlying library, you may do so by adding it to the optimizer key within config.json. For example, to increase the hero image count from 2 to 5:
{
"optimizer": {
"maxHeroImageCount": 5
}
}
Enabling KV Cache
CloudFlare Workers have access to a fast, globally available cache. We highly recommend you enable this feature. In order to use it, add enableKVCache: true to config.json, as well as specify the bindings within the wrangler.toml file. The binding must be named KV.
To see an example, check out the demo's wrangler.toml file.
Enabling image optimization
If you are a Business or Enterprise customer of Cloudflare, you may enable Cloudflare Image Optimizations. Just add enableCloudflareImageOptimization: true to the config.json file and images will be automatically optimized for multiple screen sizes.
Note: due to current limitations in workers.dev, this does not yet work in reverse proxy mode.
About
Implementation of AMP Optimizer for Cloudflare Workers