Skip to main content
2 of 3
edited title

Strategy browser game - Update tables on refresh

I am building a Travian clone for learning purposes using FastAPI for the backend. I want to update my curent logged user tables whenever he is making a new request (such as loading a new page) unlike updating tables every x seconds.

Since I am using FastAPI, I found that a middleware could be a good option to update tables for every new http request. However, there is a lot of tables that may be updated:

  • Ressources (always)
  • Ingoing attacks
  • Outgoing attacks
  • Building / Upgrading buildings
  • Building / Upgrading troops ...
  1. What would be the best approach to update my tables for every new http request? Updating every tables may be a bit more time-consuming but probably easier to manage

  2. Thi is related to question 1, but since I chose to update my tables on every call, I must store somewhere a timestamp of a column last_updated_timestamp in order to calculate the new value. Should I create this column for every tables that is re-calculated or should I hold a single last_updated_timestamp value for every table?