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

Improve object cache warning notice with host-specific instructions #1216

Closed
westonruter opened this issue Jun 18, 2018 · 11 comments
Closed
Assignees
Labels
Caching P0 High priority Performance wontfix WS:Core Work stream for Plugin core

Comments

@westonruter
Copy link
Member

westonruter commented Jun 18, 2018

There is currently a notice on the AMP settings page that links to the Persistent Caching page on the Codex:

image

The codex page is not very informative. It would be best if we detected the hosting environment and linked off to their respective support docs on enabling object caching, for example:

This information should be exposed in the Site Health check.

@postphotos
Copy link
Contributor

@westonruter, Are you aware of a way for a plugin or theme to surface the hosting platform? Agreed, that could be extremely useful for us here!

@westonruter
Copy link
Member Author

No, but usually there are some signals that can move looked at to sniff out the hosting platform. For example on Pantheon the $_ENV['PANTHEON_ENVIRONMENT' variable is defined. On WP Engine there is a certain mu-plugin installed. And so on.

@westonruter
Copy link
Member Author

As @schlessera suggested, it would be good to engage with the WordPress hosting community to put an authoritative documentation in the handbook.

@westonruter
Copy link
Member Author

Another resource to refer to: https://scalewp.io/object-caching/

@kmyram
Copy link

kmyram commented Mar 17, 2020

@westonruter
Copy link
Member Author

The handbook performance page is missing the guidance on which specific plugins to use, and what object caching is available on each host. So that would be a natural next step for that Object Cache section.

@westonruter
Copy link
Member Author

@schlessera Do you know if the hosting team has this on their roadmap?

@schlessera
Copy link
Collaborator

schlessera commented Mar 18, 2020

@westonruter westonruter added the P0 High priority label Mar 20, 2020
@westonruter westonruter modified the milestones: v1.6, v1.5.1 Mar 20, 2020
@westonruter westonruter modified the milestones: v1.5.1, v1.5.2, v1.6 Mar 31, 2020
@My1
Copy link

My1 commented May 16, 2020

another question would be whether or not this is even possible on for example a plain webhoster and if not just let the user supress the notification as there's nothing the user can do anyway

@westonruter westonruter removed this from the v1.6 milestone Jun 15, 2020
@kmyram kmyram added the wontfix label Jul 21, 2020
@westonruter westonruter assigned westonruter and unassigned amedina Jul 21, 2020
@westonruter
Copy link
Member Author

We've agreed this is not feasible to do in a general way. It is up to hosts to add this information via mu-plugins on their respective platforms.

Here's an example for how a host can override the test actions to include not only host-specific documentation link but also a button that could be used to enable object caching on their platform:

add_filter(
	'site_status_test_result',
	function ( $test_result ) {
		if (
			isset( $test_result['test'], $test_result['status'] )
			&& 'amp_persistent_object_cache' === $test_result['test']
			&& 'recommended' === $test_result['status']
		) {
			$enable_button = sprintf(
				'<button class="button button-secondary" id="foo-host-enable-object-caching" type="button">%s</button>',
				esc_html__( 'Enable Object Caching', 'foo-host-object-caching' )
			);

			$learn_more_link = sprintf(
				'<a href="%1$s" target="_blank" rel="noopener noreferrer">%2$s <span class="screen-reader-text">%3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>',
				esc_url( 'https://foo-host.example.com/object-cache/' ),
				esc_html__( 'Learn more about persistent object caching', 'foo-host-object-cache' ),
				/* translators: The accessibility text. */
				esc_html__( '(opens in a new tab)', 'foo-host-object-cache' )
			);

			$test_result['actions'] = "<p>$enable_button</p> <p>$learn_more_link</p>";
		}
		return $test_result;
	},
	20
);

add_action( 'admin_enqueue_scripts', function ( $hook_suffix ) {
	if ( 'site-health.php' !== $hook_suffix ) {
		return;
	}
	wp_enqueue_script( 'foo-host-enable-object-caching', 'https://foo-host.example.com/enable-object-caching.js', [], '0.1', true );
} );

The recommended site test result then looks like this:

image

@westonruter
Copy link
Member Author

I've opened a new issue for this and re-scoped it: #5780

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Caching P0 High priority Performance wontfix WS:Core Work stream for Plugin core
Projects
None yet
Development

No branches or pull requests

6 participants