-
Notifications
You must be signed in to change notification settings - Fork 382
Description
As a site admin running AMP on my WordPress site, I should be able to know when elements cannot be cached and I should be able to cache unique elements (via usage of uniqid() for example) when a WP theme or plugin generates this.
- AC1: Using
TwentySeventeenand its uniqid method break caching as described below. The plugin should automatically catch when a theme (such as this one) breaks caching, reporting that it cannot be fixed automatically. - AC2: Propose patch to Twenty Seventeen to use an alternative to use a counter or something more stable than
uniqid(). -
AC3: Introduce new filter to apply to buffered content which can be used (sparingly) to fixup content that would otherwise break response caching.
Twenty Seventeen uses uniqid() to generate IDs for HTML elements:
Unfortunately this causes the response to differ for each request and causes a cache MISS for the plugin's AMP response cache. The result is that the post-processor will always be invoked on a site with Twenty Seventeen, and the object cache will get polluted with values that never get used.
I'm not sure if there is something we can do to fix this. It would have been preferable if Twenty Seventeen had instead introduced a unique-ID generator like:
function twentyseventeen_uniqid() {
static $id = 0;
return ++$id;
}As this would mean the IDs would be unique within a response, but they would be repeated across multiple responses.