5e-database
5e-database copied to clipboard
Additional Response Headers
Either to the Response Headers or Response data, it would be helpful to include last-modified - a date for when the item, monster, etc. was added to the SRC or last edited. This would help identify when an individual index ( i.e animated-shield ) was last modified.
Currently date Response Header outputs today's date.
That's going to be impossible given the current architecture. We currently nuke and replace the DB each time a change is added. We would need to first shift this to be selective upsert/delete depending on what has changed, which is a non-trivial task. The only other way to handle this would be to manually set this value which is tedious and given the amount of items, potentially not worthwhile.
If you would like to take a crack at the more holistic approach, I give you full reign but it's not something I'm going to want to tackle right now given the complexity.
I can see how a Last-Modified response header would be useful for consumers who rely on caching. Perhaps a good compromise, that would be easier than redesigning the way we update the database, would be to provide the same Last-Modified datetime for every request to the API - the date when the database was last nuked/rebuilt.
The simplest way would probably just be to upsert a single document with a known _id into an admin or meta collection each time the database is deployed, which could then be queried to provide the Last-Modified date for each request.
This would take slightly less effort than running upserts/deletes for each document every time we redeploy. It wouldn't be perfectly granular, but it would allow clients to know when their caches might be out of date.
@fergcb I love that compromise. Thank you!