Here is the caching logic that I would like you to implement in globalSearch.xql.
Add an input parameter cache. If not given as an input, set a variable named cacheresult to false and don't create or use a cache file. If cacheresult is true, then create a cache file if it does not exist, otherwise create a cache file.
The cache file associated with a query should placed in a subdirectory of the cache directory named
Section/Element/Filename.xml
The contents of Filename is the string $result.
If the search was in section News, category HPDE/Meetings on element NewsDescription/Title (as a result of the search http://localhost:8080/vxoware/search.do#pagesize=50&searchsection=/News/HPDE/Meetings&startrecord=1&searchelement=/NewsDescription/Title\)
then the above would be
News/HPDE/Meetings/NewsDescription/Title/Filename.xml
Filename is determined using Filename = util:hash($string, 'md5')
where
$string = concat($searchString,'/',$sortByParam,'/',$max,'/',$start)
The idea here is that when, for example, someone modifies the Title element for a record with section News, category HPDE/Meetings, and element NewsDescription/Title, I know all files under News/HPDE/Meetings/NewsDescription/Title/ need to be deleted. In addition, I can re-create the deleted cache files by making a new query based on the file name in the directory that will be cleared.
Having $max and $start be part of $string bothers me because it increases the number of unnecessary cache files created. I think that we can safely do it as specified above and then add some logic that reduces the number of cache files created by being smarter about $max and $start. For example, if there is a cache file with $max = 10 and $start = 2, I could use the contents of the cache file created with $max=50 and $start=2 instead of doing a query.