tags:

views:

66

answers:

1

I am little bit confused on whether to cache the xml response returned from a search engine.Initially I thought of caching the response as I have to use the same response in several web parts and apply different XSLT to that response in different web parts.

But I was stuck up with a question that if I only add few web parts to a page , and if I dont have the web part with caching logic added, it might cause serious problems.

Will it be a good idea to submit the query from every web part independent of other web parts and just cache the XSLT file?

Could anyone suggest me a good option to overcome this.

Thanks

Carol

A: 

If it is the exact same XML response that is used by all of the webparts, then I think it would make sense to cache the data. You could create a class that is shared by all of your webparts that handles the caching (and getting the XML from the search engine if it does not exist in the cache).

Kit Menke
I guess the XML would vary as the XML is coming from a search engine and would vary on the search term
Pradeep007
Ahh I think I understand what you are asking now. Have you looked at Web Part Connections? http://msdn.microsoft.com/en-us/library/ms469765.aspx
Kit Menke
Here I have developed the web parts communication not by using Provider-Consumer model. Web Parts communicate with each other by reading the query string parameters from the Url.
Carol
In that case, maybe it would make sense to use a sliding cache with a small timeout (10 seconds?). The cache Key would be built using the query parameters (so that each webpart ends up with the same key per query). Also check out this link for caching info http://msdn.microsoft.com/en-us/library/bb687949.aspx as you will most likely need a lock.
Kit Menke
Thank You Kit for your kind help. I would give it a try.
Carol
Thank You Grace for your response.
Carol
Hi Kit I hjave an idea, but I dont know how good it is. Can you tell me if this is the right way to do:I have 5 different web parts-Search Box web Part, Results Web part, Paging Web Part, Navigator Web Part, Enhanced Results Web PartIn addition to these if I develop a Hidden Web Part which reads all required query string parameters and gives the Xml response.This Hidden web part will be added as soon as we add Search Box Web Part(Stapling)This hidden Web Part will act as a provider for the remaining web parts which are consumers.Does this sounds good?ThanksCarol
Carol
What you describe sounds good if you were going to use web part connections. Honestly, I think it will be more work to create another web part that provides a connection; implementing caching with a lock will be easier.
Kit Menke
Ohh ok. Then I would try doing caching. But setting the time out would be critical I guess. Thank You soo much for your help.
Carol