Open addison74 opened 9 years ago
OK, this seems to be working so far in my testing. Try changing your ESI policies for the header block to add a flush event for _controller_action_layout_render_before_catalogsearch_resultindex
<reference name="header">
<action method="setEsiOptions">
<params>
<access>private</access>
<flush_events>
<wishlist_item_save_after/>
<wishlist_item_delete_after/>
<sales_quote_save_after/>
<controller_action_layout_render_before_catalogsearch_result_index>
</flush_events>
</params>
</action>
</reference>
I'll test some more, but so far this seems to fix the problem.
I am getting a warning in Magento system.log file:
"Warning: simplexml_load_string(): Entity: line 48: parser error : Opening and ending tag mismatch: controller_action_layout_render_before_catalogsearch_result_index line 47"
Is your xml tag missing / character at the end of tag?
controller_action_layout_render_before_catalogsearch_result_index/
Nice catch - should be this:
<reference name="header">
<action method="setEsiOptions">
<params>
<access>private</access>
<flush_events>
<wishlist_item_save_after/>
<wishlist_item_delete_after/>
<sales_quote_save_after/>
<controller_action_layout_render_before_catalogsearch_result_index />
</flush_events>
</params>
</action>
</reference>
Notice the slash that was missing in <controller_action_layout_render_before_catalogsearch_result_index />
- sorry!
This fix has been committed to the default turpentine_esi.xml
Here are more details about 2 different testings. Clear Magento cache and session folders, clear you browser cache and cookies, restart varnish service.
SCENARIO 1: STARTING FROM HOME PAGE:
1) Enter the search word "soap" in your home page and click on Search button. You will get this page for search results.
2) Click on page logo for going back to Home page. You can see word "soap" is still in input search box (value="soap" in Developer Tools).
3) Click on category link Women. You can see word "soap" is not in input search box (value="" in Developer Tools). If you click on any other category link you will get the same result. Even visiting other pages like product page input search box will have no value.
Clear again Magento cache and session folders, clear you browser cache and cookies, restart varnish service.
SCENARIO 2: STARTING FROM A CATEGORY:
1) Click on category link Women and enter the search word "soap" then click on Search button. You will get the page for search results, now click again on category link Women. You can see word "soap" is still in input search box (value="soap" in Developer Tools).
2) Click on category link Men. You can see word "soap" is still in input search box (value="soap" in Developer Tools). If you click on any other category link you will get the same result.
3) Click on page logo for going back to Home page. You can see word "soap" is not in input search box (value="" in Developer Tools). Even visiting other pages like product page or cms pages, input search box will have no value.
Please RE-OPEN this issue. Thank you.
I tried this code in local.xml but still the same issue as mentioned in my images:
<reference name="header">
<action method="setEsiOptions">
<params>
<disableEsiInjection>1</disableEsiInjection>
</params>
</action>
</reference>
Let's dig this more in detail. I searched for dispatch events related to catalogsearch. This a Magento CE 1.9.2.2. Here is the list I found:
None of these worked if they are added as flush_events in turpentine header block.
If I am using any of the above having prefix controller_action_layout_renderbefore search box is acting normal, no cache issues. Now the question is what even shall I use in turpentine xml file? Anywat I will check what these events are doing into the code.
These two events are in function rebuildIndex (Regenerate all Stores index). File: app/code/core/Mage/CatalogSearch/Model/Fulltext.php (lines 79 and 86)
This event is in function resetSearchResults (Reset search results). File: app/code/core/Mage/CatalogSearch/Model/Resource/Fulltext.php (line 305)
This event is in function _getSearchableAttributes (Retrieve searchable attributes). File: File: app/code/core/Mage/CatalogSearch/Model/Resource/Fulltext.php (line 431)
I will use this event for flushing search box and see what is happening: controller_action_layout_render_before_catalogsearch_reset_search_result.
It seems to work as expected for the mentioned event. Please do your test too. Pay attention to Block HTML Output being disabled in Cache Management. If this block is enabled in my case famous "___SID issue" appears very quick. When this issue appears the URLs containing it will cache the search box (only for all category links in top navigation and footer links).
I was just able to get around to testing this change (adding a flush event for controller_action_layout_render_before_catalogsearch_reset_search_result
) and unfortunately it doesn't seem to be working. This doesn't appear to be an event that Magento actually dispatches (at least in CE).
I also tested catalogsearch_reset_search_result
and that doesn't work either. I notice in the log that the event isn't getting detected and used to flush the header block. I tested a few more as well.
I think the problem here is the sequence of events:
1) (on homepage) - enter search term and hit enter
2) as search results page is loaded, the header block cache is cleared due to the flush event controller_action_layout_render_before_catalogsearch_result_index
3) display search results page - and Varnish stores the header block (which includes the search query)
4) click on homepage - homepage loads, and the header block is loaded from varnish using the value stored in #3 above...
Theoretically, you could resolve this by setting a flush event to trigger on step 4 (when the homepage is loaded) - however in practice this would mean clearing the header block cache on pretty much any page load - which obviously isn't useful!
I don't think it's useful to spend time to come up with a fix for this specific scenario, given that I'm sure other themes will approach this differently. I'd suggest for problems like these using client-side javascript similr to that suggested in https://github.com/nexcess/magento-turpentine/pull/521 - or just alter the template for the block with the search form to not show the search query at all.
For the moment I am flashing the event I mentioned before. It is working by now: controller_action_layout_render_before_catalogsearch_reset_search_result
Is there a solution for this issue?
There is a solution in this very same post.
Which one? I've tried controller_action_layout_render_before_catalogsearch_reset_search_result. But it doesn't work.
How did you solve this?
I've just found a weird thing. It works If I logged in, but it doesn't for guests. How is it possible? @miguelbalparda @ADDISON74 @ricsipontaz @aricwatson
Unfortunately it doesn't work, just the log in action flushes the cache and it works on the first try only... Can somebody re-open this ticket? Or show me a solution?
My test version is as follows:
1) Clear your browser cache and reload your website. 2) In search box enter a word and click on Search button. See the word you searched in inside text box. 3) Click any link inside the page to visit a new page. Look again to search box. The word you searched before is still inside the box. Some other pages will have it too there, but others not. 4) If you visit again those pages with that word inside the search box, you will find it there.
This is a very basic issue I know you fixed long time ago.