Contact form 7

wanah

Well-Known Member
#1
With the WordPress plugin Contact Form 7 you have to disable cache plugins otherwise you can't submit forms (due to WordPress security that adds a hidden field to the form that is related to the visitors ip and is only valid for a sort period). Would it be complicated for Litespeed Cache to use ESI hole punching to exclude either any Wordpress forms that use the hidden field or otherwise just contactform7 forms as this is the most popular form plugin.
 

KevinFwu

Administrator
Staff member
#2
Where do you have your form? If it is just in a contact-us page, you could just do-not-cache that page.

That said, per their faqs here, the hidden fields should be valid for roughly 24 hours after it is created. If your TTL is longer than that, please shorten it to 24 hours to see if that fixes the issue.

We will consider creating an esi block for it, it shouldn't create too many problems and it will allow the whole page to be cached for longer.

Let me know if this doesn't answer your question.

Cheers,
Kevin
 

wanah

Well-Known Member
#3
Thanks, I think they use the WordPress wp_nonce_field method, so if you could detect the resulting HTML :

https://codex.wordpress.org/WordPress_Nonces#Adding_a_nonce_to_a_form

Then you could make the esi block work with all plugins and thems that use noonce fileds in their forms.

Not sure if this would even be possible but could you maybe try and find out if you could extend the wp_nonce_field to add the esi block juste around this field.

Not at all sure if this could work, but here is some completly non tested and incomplete code to illustrate my idea :

Code:
add_filter('wp_nonce_field','litespeedcache_wp_nonce_field');
function litespeedcache_wp_nonce_field( $fieldhtml )
{
return '<esi code with 24 hour private cache>' . $fieldhtml . '</esi code>';
}
The above would probably need some logic depending on what output the original function allows, and that's presuming you can even add a filter to the wp_nonce_field function.
 
Top