Caching¶
Search result caching¶
New in version 4.7.
Saved searches¶
When searching using the PUT method, the query parameter save=true
can be used save the query and request parameters for later retrieval. This can be
used to improve performance for queries that are performed frequently, as the
saved search endpoint supports conditional GET using ETag.
The response will then have status 303 See Other and Location
header, from where the search result can be fetched. The URI from the Location
header
supports the ETag
and If-None-Match
headers for GET requests.
GET requests to the location URI without the If-None-Match
header
with return the search result with it’s ETag, or 404
if the saved search has
been invalidated and removed.
For item or collection search, the saved search will be invalidated and removed if any entity of that type is re-indexed.
Note
The ETags returned from saved search requests are weak ETags; meaning that the “Content-Type” headers and query parameters won’t affect the value of the ETag.
Example¶
An item search request is first made using save=true
:
PUT API/item?save=true
Content-Type: application/xml
<?xml version="1.0" encoding="utf-8"?>
<ItemSearchDocument xmlns="http://xml.vidispine.com/schema/vidispine">
<text>squirrel</text>
</ItemSearchDocument>
HTTP/1.1 303 See Other
Location: http://localhost:8080/API/item/saved/f8297c9d02083d66731b4438415fd26b?type=ITEM
Then, to fetch the query results:
GET http://localhost:8080/API/item/saved/f8297c9d02083d66731b4438415fd26b?type=ITEM
HTTP/1.1 200 OK
Content-Type: application/xml
ETag: W/"50521d364314765d9f672279375939b8"
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ItemListDocument xmlns="http://xml.vidispine.com/schema/vidispine">
<hits>1</hits>
<item id="VX-26424" start="-INF" end="+INF">
<timespan start="-INF" end="+INF"/>
</item>
</ItemListDocument>
After that, the ETag can be used to perform a conditional GET:
GET http://localhost:8080/API/item/saved/f8297c9d02083d66731b4438415fd26b?type=ITEM
If-None-Match: W/"50521d364314765d9f672279375939b8"
HTTP/1.1 304 Not Modified