Problem/motivation
The field on the search form appears to be render cached.
Steps to reproduce
- On a clean site, configure gcs. Place the gcs block in the content region, and give permission for anon to use the search
- In a browser (browser 1) as an anonymous user, navigate to a page with the gcs block, but do not submit.
- In a separate browser (browser 2), log in as an administrator and clear the caches
- In browser 1, perform multiple searches. The search results should always be correct, but the value in the input should be stale
Proposed resolution
This module uses Gitlab CI for automated testing of proposed code changes. To contribute code changes, create a merge request. Patch files will not trigger automated testing and are not sufficient for review.
Issue fork google_cse-3545822
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
miwayha commentedI've worked around this issue with the following:
/**
* Implements hook_form_FORM_ID_alter().
*/
function mymodule_form_google_cse_search_box_form_alter(
&$form,
FormStateInterface $form_state,
$form_id
) {
$form['#cache']['max-age'] = 0;
}
The problem with this approach is that it gets autoplaceholdered, which can cause issues with bigpipe.
Comment #3
mark_fullmerThanks for reporting this. I'm thinking that the appropriate fix here, based on what you've outlined, would be to add a cache context to the block so that the render caching is able to vary by user. Something along the lines of:
Would you be able to see if the above method works for your use case?
Comment #5
mark_fullmerComment #6
mark_fullmer