←back to thread

Tower Defense: Cache Control

(www.jasonthorsness.com)
57 points jasonthorsness | 1 comments | | HN request time: 0.206s | source
Show context
ec109685 ◴[] No.44006778[source]
Regarding stale-while-revalidate, the author calculates maximum load like this: “With the options available on hn.unlurker.com, there are only 10 * 12 * 8 * 2 or 1920 possible combinations, refreshed at most once every 15 seconds”

That math works until it doesn’t. If for some reason there’s a greater than 15 second response, the cache will open the floodgate and won’t return any cached response until the cache is full.

Similarly, errors need to be accounted for. If the server returns a 500, is it configured to be cached? Is stale-while-error configured so the error state doesn’t take the server down?

replies(2): >>44007741 #>>44008459 #
1. ndriscoll ◴[] No.44007741[source]
Put nginx in front with proxy_cache_lock with a sufficiently high lock timeout. Even if your service can somehow be that slow, now you have bounded requests again.