Index: mycap.module =================================================================== --- mycap.module (revision 1357) +++ mycap.module (working copy) @@ -262,6 +262,9 @@ '#default_value' => md5(mt_rand()), ), ); + + //Save this page's URL so that we can uncache it when this form is submitted + $form['orig_url'] = array('#type'=>'hidden','#value'=>$GLOBALS['base_root'] . request_uri()); // Ugly, but necessary. if (isset($_POST) && isset($_POST['seed'])) { @@ -272,12 +275,11 @@ } $form['captcha'] += mycap_add_captcha($seed); + $form['#validate']['mycap_validate_captcha'] = array(); $form['#pre_render'][] = 'mycap_prerender_captcha'; $form['#submit']['mycap_unset_captcha'] = array(); - // Prevent caching of this page. - $GLOBALS['conf']['cache'] = FALSE; } } @@ -395,6 +397,12 @@ * @param array $form_values */ function mycap_validate_captcha($form_id, $form_values) { + + //clear PAGE cache of submitting form, if cache is turned on. Added by Eli + if (isset($_POST) && isset($_POST['orig_url']) && variable_get('cache',0)) { + cache_clear_all($_POST['orig_url'], 'cache_page'); + } + $seed = $form_values['seed']; // Compare the submitted answer to the generated answer. if ($captcha = mycap_get_cached_captcha($seed)) {