UEWBot / dipvis

Django-based visualiser for tournaments for the boardgame Diplomacy
GNU General Public License v3.0
7 stars 5 forks source link

Support caching #247

Open UEWBot opened 1 year ago

UEWBot commented 1 year ago

It would be nice if browsers could cache pages, particularly as we (currently) use periodic reloads. Django has some useful support documented at https://docs.djangoproject.com/en/3.2/topics/conditional-view-processing/. The condition decorator looks more useful than ConditionalGetMiddleware, which would still construct the page but wouldn't actually send it over the network. We probably can't provide a sensible cache expiration time, but we could provide an ETag header and avoid re-sending a page if it hasn't changed. This would probably mean adding a datetime "last modified" to the Game, Round, and Tournament models (that would also cover any modifications to related classes, so the datetime in Game would be updated if CentreCount objects were added and Round would be updated if a RoundPlayer was added, for example). This would probably be easier after issue #234 is implemented, because we'll have to trigger an update to the stored scores whenever anything in a Game, Round, or Tournament changes, and that same hook could record when that happened.