greenelab / word-lapse

Explore how a word changes over time
https://greenelab.github.io/word-lapse/
Other
6 stars 3 forks source link

Fixes caching case-sensitivity #24

Closed falquaddoomi closed 2 years ago

falquaddoomi commented 2 years ago

The caching library we're using, fastapi-redis-cache, uses the verbatim (i.e., case-sensitive) arguments to an endpoint to determine if there's a cached response available or not. This occurs before the endpoint's handler is entered, causing every case variant to be a cache miss even if we lowercase the token in the endpoint handler (as I was naively doing before).

To get around this without having to modify the caching library, I've added a decorator lowercase_tok() that runs before the cache decorator, so the decorator ends up seeing the lowercase version of the query token instead and can correctly return a cached version should one exist.

netlify[bot] commented 2 years ago

✔️ Deploy Preview for word-lapse canceled.

🔨 Explore the source changes: 5b41f78a188a9168bbfb12bd72bb4364d136f550

🔍 Inspect the deploy log: https://app.netlify.com/sites/word-lapse/deploys/621fd9710fd4560007014188