Topic: How often/when does the autocomplete cache get updated?

Posted under General

For example, last week I created the tag padlock_necklace, because one of the characters in a currently ongoing comic is wearing one and it was an accessory I'd seen so many times before I was surprised such a tag didn't already exist. Today was the first time I didn't have to type out the full name of the tag for it to show up in the autocomplete. I've also had similar experiences with new character tags.

I usually observe the tags I've created appearing in the autocomplete searches on the same day I create the tag.

Looking at the actual headers that autocomplete.json responds with though, it instructs your browser to keep the cache for 7 days.

Cache-Control: public, max-age=604800

From experience I know there's no way that the server itself actually caches it for that long.

The autocompletion search is handled by autocompleted so we can take a look at its source on GitHub.

let cache = CacheBuilder::new(15_000)
    .time_to_live(Duration::from_secs(6 * 60 * 60))
    .build();

(source)

Assuming these values are the same in production, the cached result lives for up to 6 hours - even shorter if more than 15,000 results are being cached first. This is also assuming that nginx, Cloudflare or anything else isn't also caching anything.

I guess the big difference here is that your browser is actually listening to the 7 day cache length, and mine isn't.

  • 1