Support » Plugin: Cache Enabler - WordPress Cache » Home Page Form Doesn’t Work with Cache

  • Resolved seanthompson

    (@seanthompson)


    Hi,

    I switched a couple of sites, including my own, to Cache Enabler. I use A2 Hosting with Litepeed (Turbo page cache disabled). Cache Enabler is the simplest, fastest page cache out of everything I tested, so I’d like to use it, however, I’m having one problem…

    I have the contact form on my own site in the footer, so it’s on every page. When I have Cache Enabler activated, the form doesn’t submit on the home page. When the form submits, the page reloads with a string added to prevent re-submission if the page is refreshed afterword. I think this is where the problem is.

    (I’m using the advanced .htaccess code. It makes no difference whether I use it or not.)

    This is the code in the form that handles the reload…

    if ( wp_mail( $to, $emailsubject, $body, $headers ) ) {
                    
                    header ("Location: $reload?success=true#footer");
                    exit;
                    
                }

    This adds /?success=true#footer to the url.

    The only time it ever fails is on the home page with Cache Enabler activated.

    The page just reloads without the string.

    Cache Enabler seems to be caching the string only on the home page…

    1. I submit the form with Cache Enabler deactivated.
    2. View page source at view-source:https://oldtownweb.com/?success=true#footer.
    3. Reactivate Cache Enabler
    4. Refresh home page.
    5. Refresh view-source:https://oldtownweb.com/?success=true#footer.

    view-source:https://oldtownweb.com/?success=true#footer shows Cache Enabler comment at bottom.

    If I repeat the same process on another page, no comment in source.

    Is this something I can fix in Cache Enabler settings?

    I’m also getting errors when activating/deactivating Cache Enabler on all sites, not just this one. Not sure if it’s related.

    In wp-admin upon deactivation…

    Warning: include(/home/oldtownw/public_html/wp-content/advanced-cache.php): failed to open stream: No such file or directory in /home/oldtownw/public_html/wp-settings.php on line 84

    In error log…

    2019-10-26 09:25:39.061870 [NOTICE] [70.15.17.105:60604:HTTP2-1] [STDERR] PHP Warning: Invalid argument supplied for foreach() in /home/oldtownw/public_html/wp-admin/includes/plugin.php on line 1498
    2019-10-26 09:25:39.061789 [NOTICE] [70.15.17.105:60604:HTTP2-1] [STDERR] PHP Warning: Invalid argument supplied for foreach() in /home/oldtownw/public_html/wp-admin/includes/plugin.php on line 1498
    2019-10-26 09:24:37.540497 [NOTICE] [70.15.17.105:60548:HTTP2-5] [STDERR] PHP Warning: include(/home/oldtownw/public_html/wp-content/advanced-cache.php): failed to open stream: No such file or directory in /home/oldtownw/public_html/wp-settings.php on line 84
    2019-10-26 09:24:31.662232 [NOTICE] [70.15.17.105:60548:HTTP2-1] [STDERR] PHP Warning: Invalid argument supplied for foreach() in /home/oldtownw/public_html/wp-admin/includes/plugin.php on line 1498
    2019-10-26 09:24:31.662166 [NOTICE] [70.15.17.105:60548:HTTP2-1] [STDERR] PHP Warning: Invalid argument supplied for foreach() in /home/oldtownw/public_html/wp-admin/includes/plugin.php on line 1498
    2019-10-26 09:23:23.038471 [NOTICE] [70.15.17.105:60492:HTTP2-1] [STDERR] PHP Warning: Invalid argument supplied for foreach() in /home/oldtownw/public_html/wp-admin/includes/plugin.php on line 1498
    2019-10-26 09:23:23.038402 [NOTICE] [70.15.17.105:60492:HTTP2-1] [STDERR] PHP Warning: Invalid argument supplied for foreach() in /home/oldtownw/public_html/wp-admin/includes/plugin.php on line 1498
    2019-10-26 09:21:42.715460 [NOTICE] [70.15.17.105:60408:HTTP2-1] [STDERR] PHP Warning: Invalid argument supplied for foreach() in /home/oldtownw/public_html/wp-admin/includes/plugin.php on line 1498
    2019-10-26 09:21:42.715385 [NOTICE] [70.15.17.105:60408:HTTP2-1] [STDERR] PHP Warning: Invalid argument supplied for foreach() in /home/oldtownw/public_html/wp-admin/includes/plugin.php on line 1498
    2019-10-26 09:20:42.718613 [NOTICE] [70.15.17.105:60359:HTTP2-1] [STDERR] PHP Warning: Invalid argument supplied for foreach() in /home/oldtownw/public_html/wp-admin/includes/plugin.php on line 1498
    2019-10-26 09:20:42.718524 [NOTICE] [70.15.17.105:60359:HTTP2-1] [STDERR] PHP Warning: Invalid argument supplied for foreach() in /home/oldtownw/public_html/wp-admin/includes/plugin.php on line 1498

    Thanks in advance,
    Sean

    The page I need help with: [log in to see the link]

Viewing 11 replies - 1 through 11 (of 11 total)
  • Hi,

    I’m just wondering if you have any updates on this. I got a test submission through the form a few days ago. I have the cache disabled for now, because I don’t want to leave the form inoperable.

    By default the Cache Enabler plugin cache will be bypassed with most query strings, however, there are a few that won’t. (The regular expression that won’t bypass the cache can be found in the Cache Inclusions setting.)

    In your case ?success=true#footer should bypass the cache. Can you please temporarily enable the Cache Enabler plugin on your website again so I can replicate the issue? If this isn’t possible do you have a staging environment that I can replicate this issue on?

    Sorry for the late reply, I didn’t get the email notification.

    I’ll turn on caching.

    Thank you,
    Sean

    Thank you, I was able to replicate the issue. It appears that the issue is the POST request being made when submitting the contact form on your home page is returning a 200 response status code instead of a 302 (like on all of your other pages). To troubleshoot this further, can you please answer the following questions at your earliest connivence:

    1. Do you have any other layers of caching enabled? (Other than the layer that you mentioned you have already disabled.)
    2. Do you have any Cache Inclusions defined?
    3. Have you been able to temporarily disable other plugins to completely narrow down if this issue is actually caused by the Cache Enabler plugin?

    Sure.

    1. I have opcache enabled
    2. No cache inclusions
    3. I disabled all plugins, deactivated Cache Enabler, tested, reactivated and tested, several times.

    Thanks for the additional information. Does this still occur after OPcache is disabled and the Cache Enabler cache is cleared?

    Yes. I disabled opcache, cleared cache, and the problem remains.

    coreyk

    (@coreyk)

    To confirm, there is a 302 redirect to /?success=true#footer when the Cache Enabler is disabled and the contact form is submitted on your home page?

    To troubleshoot this issue further, what contact form plugin is currently being used? Does this still occur with other contact form plugins as well?

    seanthompson

    (@seanthompson)

    Yes, It works the same as every other page when the cache is disabled.

    I’m not using a plugin. The form action is in the footer template above the form.

    I moved the action for the form to a plugin and to use admin-post.php on my test site. The form submits, however the success message that still relies on the redirect doesn’t show. I’m going to make the same change on this site as well, so if someone fills out the form, at least I’ll get the message.

    seanthompson

    (@seanthompson)

    OK, I made these changes to the form on my site. Just like the test site, the form submits (I get the email and the submission is entered into the database) still no success message. I included…

    function success_message() {
        
        if (isset($_GET['success'])) {
        
        echo '<p class="success">Thanks for contacting me. Expect a response soon.</p>';
        
        }
        
    }

    in the plugin and…

    <?php success_message(); ?>

    above the form in the footer template. Works when cache is disabled, not with cache activated.

    I appreciate the time you spent trying figure this out. I’m going to switch to another plugin for this site. Cache Enabler is still the fastest, and I’ll use it on other sites. This seems to be an odd case where there’s an issue.

    Thank you for looking into it.

    Sean

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