wuvt / trackman

WUVT's track logging web-app
GNU Affero General Public License v3.0
4 stars 3 forks source link

Remove Redis caching and instead use HTTP caching #76

Closed mutantmonkey closed 4 years ago

mutantmonkey commented 5 years ago

The existing Redis caching was unnecessarily complicated and reimplemented something that reverse proxies can already do for us better. This change adds Cache-Control and Last-Modified headers where appropriate so that caching can be handled by a reverse proxy.

As with the built-in caching, the playlists cache will be invalidated as needed to ensure we don't serve stale data. As a result, cached playlists requests will still hit the app server, but the conditional request logic will prevent those requests from hitting the database.

It's important to note that right now, some special handling is required to implement this with Nginx and retain client-side conditional request logic for the playlists cache. The best way to do this is add a special location block for /api/charts and implement server-side caching in that block only. Otherwise, Nginx will handle the If-Modified-Since header itself and never pass it on to the app server except for validating its own cache.

g-i-g commented 5 years ago

Looks alright from here

mutantmonkey commented 5 years ago

Alright, this should actually be ready for merge now.

mutantmonkey commented 5 years ago

I'm having some second thoughts about this approach and I may end up abandoning it. This just makes cache invalidation a bit too tricky.