On node build captcha_element_process() is called which disables caching for the page.
This is done even if the form element is not displayed. For example: when having a webform that uses captcha and the webform node is displayed in a view mode that only shows the title and the body (some sort of teaser, but not actually the teaser view mode).
So I think the page cache should be disabled in the rendering process when the field is displayed. If the field is not displayed, the user is trusted, the page is not cached anyway for of the same reason.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | captcha-improve-cache-handling-2465113-2.patch | 1.86 KB | fabianx |
| #1 | captcha-improve-cache-handling-2465113-1.patch | 2.5 KB | mfernea |
Comments
Comment #1
mfernea commentedHere is the patch.
Comment #2
fabianx commentedI 100% agree with the #1 comment here.
I extended the patch to add a comment why the page cache can be disabled very late.
Comment #3
plachI agree that deferring the choice of disabling page cache to the point where we are sure that the captcha would actually be displayed, unless there's a reason to skip it, is sensible. We still ensure every untrusted user sees the captcha, but we avoid the performance penalty in situations where the captcha would never appear.
Comment #4
wundo commentedComment #6
wundo commented