As form API is a little slower than just gluing together HTML chunks, and these forms are present on every page, it could be a small performance boost to cache them. And they never change so they are ideal candidates.

Did some cleanup in search_form.

Comments

dries’s picture

Version: 4.6.3 » x.y.z

Benchmark results needed to back this up.

Steven’s picture

The 86400 is obviously supposed to be some timeout, but you are passing it for $headers instead. CACHE_PERMANENT is the timeout value instead (i.E. never).

chx’s picture

StatusFileSize
new3.81 KB

Obviously. I really do not know whether I'll be able to show benchmarks, but I'll try some.

moshe weitzman’s picture

Status: Needs review » Needs work
chx’s picture

yes it needs more work because we should not even try to cache when there is a POST -- login won't work!

chx’s picture

Component: base system » forms system
Status: Needs work » Reviewed & tested by the community
StatusFileSize
new6.01 KB

This patch does caching in form API. The change is as little as possible, it saves the #elements['children'] to cache and loads it back directly. You can specify a cache id but if you don't then form API will generate one for youl

moshe weitzman’s picture

Priority: Critical » Normal
Status: Reviewed & tested by the community » Needs review

this is a pretty interesting patch. i will try to get some benchmarks for it. assigning to me. and marking as 'needs review' for now. its power may be more evident on more complicated forms that are cacheable.

chx’s picture

StatusFileSize
new4.79 KB

rerolled against HEAD

moshe weitzman’s picture

Status: Needs review » Needs work

1 hunk failed

chx’s picture

Status: Needs work » Needs review
StatusFileSize
new4.8 KB

Rerolled.

moshe weitzman’s picture

i tried to bechmark this but siege/ab were giving too much variation between requests to give good results. i tried our timer API but couldn't persist through all the instrumentation needed to measure this way. hopefully someone else can benchmark this.

killes@www.drop.org’s picture

I've benchmarked the search form and did not find a statistically significant difference in page execution times.

Tobias Maier’s picture

I can't comment on the page execution times...

But I think we can use this for the contact module too...
and that we can see real benefits if we cache parts of node/add/X, node/edit/X and modules... (like simple_access)

chx’s picture

Title: cache short search and user login forms » form cache mechanism
StatusFileSize
new1.73 KB

you provide #cache => TRUE on any form element and it gets cached.

Much better than any patch so far.

moshe weitzman’s picture

can we get at least one implementation as well? makes it easier to test and more obvious how to use this.

moshe weitzman’s picture

can we get at least one implementation as well? makes it easier to test and more obvious how to use this.

drumm’s picture

Version: x.y.z » 6.x-dev

I'm guessing something like this will be for 6 at this point.

keith.smith’s picture

Status: Needs review » Needs work

patch does not apply

# patch -p0 < form_cache_2.patch
patching file includes/form.inc
Hunk #1 FAILED at 263.
Hunk #2 succeeded at 555 with fuzz 2 (offset 27 lines).
Hunk #3 FAILED at 627.
Hunk #4 FAILED at 686.
3 out of 4 hunks FAILED -- saving rejects to file includes/form.inc.rej

pancho’s picture

Version: 6.x-dev » 7.x-dev

Moving this again - this time to the D7 queue.

BioALIEN’s picture

Wow this patch has lasted a few years. As it's marked for D7, does it make sense to also start thinking about caching CCK generated forms?

casey’s picture

We do have all kinds of new caching mechanisms for forms in D7. Is this issue fixed by them?

sun’s picture

Status: Needs work » Closed (won't fix)

I may be mistaken, but I don't think that this patch makes any sense today.