Support » Plugin: AMP » Redis Cache Pro causing conflicts with AMP sitescan

  • Resolved fidoboy


    For anyone interested, the plugin Object Cache Pro is causing conflicts with AMP and as a result the sitescan fails to complete with an error message.

    The solution is to remove the analytics footnotes in WP_REDIS_CONFIG.

    Something like this:

    define('WP_REDIS_CONFIG', [
    'analytics' => [
    	'footnote' => false

    May be also AMP plugin developers could take this into account and discard any additional characters received after the closing bracket in JSON response, because it’s not the first simmilar conflict with this caracteristics (it happened also in the past with litespeed comments being added to responses)


Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Support Milind More


    Hello @fidoboy

    Thank you for letting us know, I will discuss this with the dev team and check what we can do to prevent it.

    Plugin Support Milind More


    @fidoboy As we didn’t receive a response I’ll mark this as resolved. Feel free to open a new support topic if you require any further assistance.

    Thread Starter fidoboy


    As I’ve said, the solution on your side, to prevent this kind of problem, is to sanitize the received JSON response, cleaning all characters after the last closing bracket. This is related to the Redis Object Cache Pro plugin, but it could be any other. I understand that there is no bug on this plugin because the one that it’s adding additional text into the JSON is another plugin. But it can be avoided, as I’ve said, by sanitizing the JSON before using it with your code.

    Plugin Author Weston Ruter


    @fidoboy This isn’t the case, actually. The problem is likely that the other plugin is starting an output buffer before our output buffering has started. This means that when our output buffer closes, there is no HTML comment present and thus nothing for us to sanitize. Then when the enclosing output buffer is closed, the other plugin amends an additional HTML comment. It may even be that the caching plugin is running so early to serve the cached response that the AMP plugin never even is initialized.

    Fundamentally, any such caching plugin should check the content-type of the response before assuming it can append some HTML comment. If the content-type is not text/html, then any logic to append an HTML comment should be disabled.

    Thread Starter fidoboy


    I see. Thanks a lot for the explanation. Anyway I believe that latest available version of Object Cache Pro plugin solves the issue with a new available filter. I hope that my warning here could help any other user experiencing this problem with the solution to it.



    add this code in wp-config.php but not working showing site scan faild

    Support UUID: ampwp-125f0cfc-a56d-5cd4-82ee-2839ba684f96

    @westonruter @milindmore22, most plugins check for wp_is_json_request(), but the AMP “Site Scan” doesn’t send proper request headers. Seems like an oversight on your end?

    If you can suggest a reliable way to check response headers that WordPress sent, please let me know.

    It looks like await fetch is requesting amp_validate without asking for JSON, but the response is JSON, so we’re a bit blind on our end.

    Plugin Author Weston Ruter


    @tillkruess That is correct. The amp_validate query parameter is triggering the output buffer to capture the generated page, analyze it, and then return JSON (including the appropriate Content-Type header) instead of HTML. We’re not sending an Accept request header to explicitly request JSON because we want WordPress to generate HTML which we then convert to JSON when the response is sent. If we explicitly requested JSON then WordPress could opt to generate JSON instead of the HTML that we’re needing to validate.

    As for checking the response headers that WordPress sent, you can see the headers that PHP has sent via the headers_list() function. The plugin is actually using this function to determine the response type already, and if the response is not HTML then the post-processing is aborted. If I understand correctly, this could similarly be done by your caching plugin.

    Annoying that you don’t send the Accept header, but that’s WordPress I guess.

    Are you guys using apache_response_headers() as well, or only headers_list()?

    Plugin Author Weston Ruter


    Only headers_list()

    I’ll get this included in Redis Object Cache and Object Cache Pro.

    Till Krüss


    @westonruter: This was fixed in Object Cache Pro v1.18.0 a couple of days ago 👍

Viewing 13 replies - 1 through 13 (of 13 total)
  • You must be logged in to reply to this topic.