Skip to content

Improve caching of externally-fetched stylesheets #4293

@westonruter

Description

@westonruter

When AMP_Style_Sanitizer::fetch_external_stylesheet() fails to fetch an external stylesheet, it caches the a WP_Error in the transient as opposed to the stylesheet string. In both cases, the transient expires after a month. This should be more dynamic, namely:

  • Fetches that result in failures should be cached for a DAY_IN_SECONDS rather than MONTH_IN_SECONDS.
  • Fetches that are successful should actually use a transient expiration that reflects the Cache-Control response header, as long as the max-age is greater than some minimum amount (e.g. 1 day).

See also this todo:

* @todo Use Cache-Control max-age for transient.

Originally referenced in in #2449 (comment).

Metadata

Metadata

Assignees

Labels

CSSP0High priority

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions