• Resolved gab81

    (@gab81)


    hi there

    I just realised the form isn’t working with Cloudflare on – massive issue for me as i want to have it on.

    As soon as i enable Development Mode (bypass) it works immediately and i get emails. With CF on it says “Your form submitted successfully!” green checkmark but no email and nothing registered in the WP Dashboard either.

    Is there a way to have it working with CF on? I am using these page rules:

    Cache Level:?Cache Everything,?Edge Cache TTL:?a month

    thanks,
    Gabrio

Viewing 10 replies - 1 through 10 (of 10 total)
  • Thread Starter gab81

    (@gab81)

    i’ve managed it myself ??, create a Cache rule to bypass /wp-admin/admin-ajax.php and it works!

    Thread Starter gab81

    (@gab81)

    hi,

    I thought this was fixed but it isnt.

    Quick background, so i have Cloudflare on my website, works great and caches everything.

    As previously mentioned, I set to “bypass cache” with a cache rule for -> /wp-admin/admin-ajax.php

    While it does work, it seems to be just temporary, as in after 10-12 hours for some reason, i don’t receive anymore emails from it (nor in the WP admin dashboard) (however it shows the green message “Form submitted”). Last night at 22.00 worked, this morning at 08am not working anymore. (nothing changed).

    This morning i went to CF dashboard, cleared cache for /wp-admin/admin-ajax.php (just in case), and no change, still no submit.

    Then, cleared cache for the entire page only (not the whole site) -> https://www.gabriolinari.com/contact/ and then form works again. So it’s something on the page’s code.

    After a few tests, it still works, however i am wondering why after 10-12 hours on cache then it stops working again? Bizarre.

    Question

    Are there any .php files similar to the ajax i already set to “bypass cache” that i could also bypass? How does the form submit data? What script/etc does it pull up?

    I rather not choose to bypass cache for the entire contact page, if possible, however if no solutions avail, i will do that.

    Please let me know, thank you ??

    Gabrio

    • This reply was modified 8 months, 2 weeks ago by gab81.
    • This reply was modified 8 months, 2 weeks ago by gab81.
    • This reply was modified 8 months, 2 weeks ago by gab81.
    • This reply was modified 8 months, 2 weeks ago by gab81.

    Dear Gabrio,

    Thank you for providing the information.

    I will promptly discuss this matter with our technical team and keep you updated on any progress. Please note that due to the weekend, it may take some time to resolve the issue, as our technical team is not available during the weekend.

    We appreciate your patience and understanding.

    Regards,
    Sumit

    Thread Starter gab81

    (@gab81)

    No problem, thank you! ??

    Thread Starter gab81

    (@gab81)

    i’ve removed the recapctha – testing a further 10-12 hours from now. after removal and checking the contact page, it works (with full cache switched on).

    Thread Starter gab81

    (@gab81)

    hello,

    Update:

    It’s been 21 hours since clearing cache on CF yesterday. Form perfectly works. So, looks like the REcapctha is the issue here. Good i don’t get much spam (for now) so could stay off.

    I was using captcha v2 on Gutena’s settings, i could test v3 as well.

    Considering CF Cache bypass for /admin-ajax.php does its job, is there a similar .php or .js file used when REcapctha is on that i could bypass so it does not interfere with the form?

    thank you,
    Gabrio

    Thread Starter gab81

    (@gab81)

    hello, me again, I went to the bottom of this and analysed the code entirely, please share this with your developers:

    Just after exactly 24 passed, the form started not working again, hence it’s not the captcha – i thought there must be something that changes after 24 hours but gets blocked because CF doesn’t serve it due to cache.

    I dug deeper and,

    With a bit of help of ChatGPT, I discovered that the issue is with the “nonce”, which is issued by WordPress and expires after 24 hours. Since i have a cache rule “cache everything for 1 month”, WordPress issues a new nonce after 24 hours, Cloudflare still serves the “expired” one, WordPress isn’t happy and voilà form is stuck and no email.

    “nonce”:”e944626262″ this is unique and refreshed every 24 hours.

    A simpler approach might be to dynamically load the nonce on the client side via AJAX. This would keep pages cacheable while ensuring that a valid nonce is always used for form submissions. This might involve some changes on the plugin side by your developer.

    Workarounds possible are:

    • Entirely disable CF cache for the contact page (not great for international traffic)
    • Change global caching policy to 20 hours (not great also)
    • Change caching policy only on the contact page to 20 hours (this way contact page is still fast and nonce should work)

    I just went with option 3, which i think is the best one, everything can remain cached up to 1 month, whereas the contact page will refresh every 20 hours, allowing the new nonce to work.

    Back in 24 hours again.

    Best Regards,
    Gabrio

    • This reply was modified 8 months, 2 weeks ago by gab81.
    • This reply was modified 8 months, 2 weeks ago by gab81.
    Thread Starter gab81

    (@gab81)

    Haven’t heard back from you anymore, wanted to let you know that with CF setting to 8 hours for the contact page it works, problem seems solved.

    Dear @gab81,

    Hope you are doing well.

    Dynamically loading a nonce on the client side via AJAX can introduce security risks and is generally not recommended.

    I’m glad to hear that setting the cache expiry to 8 hours for the contact page has resolved the issue!

    If you have any further questions or need assistance with anything else, please feel free to reach out.

    Regards,
    Sumit

    Thread Starter gab81

    (@gab81)

    Indeed cheers. One last thing: i’ve noticed that there’s a time, maybe once in a day only, when the form submits and it doesn’t give you the green “Message sent” – in that case there’s no email received, cache or not cache. Please let the dev know. Server is fine and load is low. cheers

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Form doesn’t work with Cloudflare on’ is closed to new replies.