• Resolved Seagull87

    (@flagship890)


    Hi
    We have litespeed and wpforms on > 1,600 sites.
    On the pages with contact forms, wpforms have a data-token that gets regenerated every 2-3 days.
    Our cache ttl is set to 7 days.
    Is there a way in litespeed we can specifically exclude just that token from getting cached without knowing which page it will appear on?

    Example:
    <form id=”wpforms-form-6″ class=”wpforms-validate wpforms-form” data-formid=”6″ method=”post” enctype=”multipart/form-data” action=”/contact/” data-token=”051c073255dc26a315d3ecbd1affa9a5″>

    We know wpforms have provided a way to extend the token via functions.php but I’m wondering if there’s a way to do it via litespeed.
    It actually doesn’t seem to break as often as we’d expect it to. Could litespeed be purging pages after a contact form is submitted?

    Thanks.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Could litespeed be purging pages after a contact form is submitted?

    Yes, LiteSpeed is able to do that, but there is more than 1 way to do that.

    Add code below to your .htaccess. Not tested, but should work:

    RewriteCond %{REQUEST_METHOD} ^POST$
    RewriteRule ^/?contact/ - [E=cache-purge:/contact/]
    Plugin Support qtwrk

    (@qtwrk)

    or use purge api https://docs.litespeedtech.com/lscache/lscwp/api/#purge with wpforms_process_complete hook

    Thread Starter Seagull87

    (@flagship890)

    Sorry I should clarify as few things.
    As we have so many sites, we have no reliable way to know which pages have a contact form. So excluding all the contact form pages from being cached via url isn’t an option.

    I had been wondering if submitting a contact form already automatically triggered a purge. I tested it there myself and it does, which would explain why the problem doesn’t come up very often.

    wpforms_process_complete hook is a good option thanks, I’ll probably try it with wpforms_frontend_output_before though as a purge seems to happen on successful contact forms anyway.

    @flagship890

    FYI: LiteSpeed cache is a URL based fullpage cache. Without any URL it would not work, but basically you are right. A form must not be purged or excluded from being cached if it is send with POST method. POST requests are automatically excluded from being cached. wpforms uses POST, but seems to have any script support and in this case cache plugin doesn’t recognize it.

    You must not check each installation if it has a form or not. Add the code regardless if any form exists. The code only works if there is a form like wpforms. Nothing goes wrong if there is no form.

    Thread Starter Seagull87

    (@flagship890)

    Thanks for your help. I’m going to look into the litespeed crawler or reducing our TTL way down.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Token in wpforms’ is closed to new replies.