Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add caching of post processor output #959

Closed
westonruter opened this issue Feb 14, 2018 · 2 comments
Closed

Add caching of post processor output #959

westonruter opened this issue Feb 14, 2018 · 2 comments
Assignees
Labels
Milestone

Comments

@westonruter
Copy link
Member

The preprocessor/sanitizer can be an expensive series of operations. If we take a hash of the pre-sanitized HTML and use this as the cache key for caching the sanitized output, it would be possible to short-circuit the entire sanitization process by serving the cache output directly. This would not preclude full page caches since PHP would still be generating the buffered output, but it would be a good way to augment full page caches. Props @ThierryA for the idea.

@westonruter
Copy link
Member Author

westonruter commented Apr 3, 2018

This can be done after #1048 since it includes the Server-Timing response headers which are key for verifying that it is working.

The cache key used for should consist of a hash of the output buffer with the plugin version and perhaps the list of sanitizers and embed handlers being used. If a plugin or theme is installed which adds another sanitizer or embed handler, this will impact the sanitizer/post-processor output, so it should be part of the cache key.

Reference the code used in the CSS processor caching: https://github.com/Automattic/amp-wp/blob/14c22c2f25490df3d1899fa1f71e969574372d90/includes/sanitizers/class-amp-style-sanitizer.php#L496-L515

I don't think that a transient should necessarily be used for caching the output since if an external object cache is not installed this can result in the options table exploding with transients. That being said, transients are being used now to store the result of image dimension lookup requests, but that is not ideal either. See also #960 where we'll warn users that they should have an external object cache present.

@westonruter westonruter added this to the v1.0 milestone Apr 3, 2018
@ThierryA ThierryA self-assigned this May 16, 2018
@westonruter
Copy link
Member Author

Caching should be disabled if WP_DEBUG is enabled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants