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

[1.x] Redirecting to non-amp version for some reason. #1369

Closed
jukefr opened this issue Aug 28, 2018 · 2 comments
Closed

[1.x] Redirecting to non-amp version for some reason. #1369

jukefr opened this issue Aug 28, 2018 · 2 comments

Comments

@jukefr
Copy link

jukefr commented Aug 28, 2018

What I did :

  • 1.0 beta 2 installed
  • Paired mode, every content type/template checked, rest is not

When I visit an AMP page via the admin menu or direct link I get directed to /?amp then /?amp-validation-errors-xx and this redirects me to / which means I cannot reach the AMP page.

If I activate the Automatically accept sanitization for any AMP validation error that is encountered. option then the ?amp will work, and not redirect me to /.

No logs regarding this problem appear in my debug.log so I cannot help much more.

@westonruter
Copy link
Member

@jukefr The redirection is happening because there are unaccepted validation errors, as you note. So when accessing the ?amp URL then it redirects to a URL like ?amp_validation_errors=3, and then this query parameter is stripped from the URL via JavaScript to leave you on the non-AMP page. You should then see in the admin bar:

image

But you're saying that when you click “Re-validate” it fails with a timeout error. There's nothing in the debug log because the error is right there, a timeout.

What I suggest to try is to increase the timeout for the AMP validation loop requests by putting code like the following in your custom theme's functions.php or into a custom plugin:

// Increase timeout for AMP validation requests from 15 to 60 seconds.
add_filter( 'http_request_args', function( $args, $url ) {
	$query = wp_parse_args( wp_parse_url( $url, PHP_URL_QUERY ) );
	if ( isset( $query['amp_validate'] ) ) {
		$args['timeout'] = 60;
	}
	return $args;
}, 10, 2 );

Issues related to timeout were previously explored in #1166, where the timeout was increased from 5 seconds to 15 seconds by default. I'm curious how quickly pages are being generated in other cases:

  1. How long does it take a page to be generated without AMP?
  2. How long does it take a page to be generated with AMP when auto-sanitization is performed? (This is a normal frontend response for visitors.)
  3. How long does it take a page to be generated with AMP with validation error sourcing being performed? (This is the request made when updating a post or re-validating a URL for errors.)

The two latter points each involve extra overhead not incurred by the previous two steps. You can manually perform the last step in your browser by making a request with /?amp&amp_validate in the URL. You'll be able to to see the JSON blob in an HTML comment at the end of the document for what is then read by the plugin to populate the validation errors in the admin.

@westonruter
Copy link
Member

I'm closing this in favor of your other ticket since it's really the same issue.

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

No branches or pull requests

2 participants