Using .Net web api
I have a web page that renders a collection of items depending on filter values applied via an ajax call to an api endpoint.
The items are paged so that if the user scrolls to the bottom of a page then another ajax call to the api with the required page number of the next set of items is made.
I have just had a request to randomise all of these items daily.
The obvious issue here is the ajax paging - each call retrieves the next set of items which at the moment is easy as the order of those items does not change. So if we are randomising, I cannot simply randomise each call.
So I guess I need some sort of caching...
These are thoughts so far:
- At midnight, all items are loaded into the cache with some sort of date-based version key (based on server time).
- Any client calls that are page 1 items will always get the cache's latest version using the date-based key. The page 1 response will return the cache key to the client (along with the data) so that any calls for pages greater than 1 will require the cache version key.
- To deal with the possibility of a user making a page 1 request to the api at 23:59:59 and then a page 2 request after midnight at 00:00:30 we could expire cache versions after 36 hours. However, new cache version is created every 24 hours at midnight.
This is the general direction I'm considering.
Does anyone have any wise words?