I'm designing a RESTful web service, and trying to come up with a good way to handle caching and synchronization of collections of items. I've read about the use of Etag and If-None-Match headers for optimizing the caching of individual resources, and I'm wondering if they can be (or should be) used for collections.
I'm interested in your feedback on the following approach:
Question - am I subverting the semantic meaning of a GET by only returning the newer items in #4, rather than the whole collection (which would include items already cached on the client)? Or does this seem like a reasonable approach? Can you suggest alternative approaches that would be better?
Thanks in advance.
Usually, it is up to the client to do the ETAG comparison after a HEAD request, and if necessary, follow-up with a more specific request (a range request or a query for entries newer than a certain timestamp). There server should simply serve-up the requested resources.
The idea is that intermediary caching proxies can be inserted in the chain of communication without either the client or server having to change its code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With