• Posts
  • RSS
  • ◂◂RSS
  • Contact

  • Careful with Caching

    August 7th, 2022
    tech
    A friend recently shared this graphic on Facebook:

    (I've added the "wrong" overlay.)

    This is clearly incorrect: there's no way Massachusetts has more prisons than colleges. (MA actually has the largest ratio of colleges to prisons in the US.) After putting a link to the original source in the Facebook discussion, however, we found something pretty weird: people on mobile were seeing the incorrect map, but people on desktop were seeing a corrected one:

    It turns out that Facebook was appending a tracking parameter, ?fbclid=... on desktop, but not on mobile. Normally this wouldn't do anything, because the site would ignore that in determining what page to return, but this site is apparently configured with a cache.

    Many sites use caches to make it easier to serve pages. If you ask them for a page they'll give it to you (which might require a lot of work to generate) and then save a copy. Then when someone else asks for the same page, they can return the saved copy instead of putting in all that work to regenerate it. The site has a cached copy of /usa-prison-v-college in its cache with outdated content, but since ?fbclid=... is always followed by a new token those requests will never be found in the cache, and they return the current, corrected, page.

    If you have a cache, what do you do when you change the page, like they did here? There are two main approaches:

    • Have a way to tell the cache the page has changed and it should forget its copy.

    • Always cache for a short time. Even just one minute can take a lot of load off a server that is getting thousands of requests for a hot page.

    In this case they apparently didn't do either: we were running into this yesterday, and as of right now the site is still returning incorrect data.

    (On the original question, comparing the number of colleges to the number of prisons is pretty silly: if one state runs large prisons and small colleges is that any better than a state that does the reverse? Comparing the number of people in prison vs college would make much more sense.)

    Comment via: facebook

    Recent posts on blogs I like:

    Futurist prediction methods and accuracy

    I've been reading a lot of predictions from people who are looking to understand what problems humanity will face 10-50 years out (and sometimes longer) in order to work in areas that will be instrumental for the future and wondering how accurate thes…

    via Posts on September 12, 2022

    History of group sleeping

    Not as normal as it once was The post History of group sleeping appeared first on Otherwise.

    via Otherwise August 10, 2022

    On the Beach

    I really like going in the water and this beach is a great place for building sand castles and boogie boarding. I also like trying to float on top of big waves. I'm not very good at it. I only float on the flat waves.

    via Anna Wise's Blog Posts July 12, 2022

    more     (via openring)


  • Posts
  • RSS
  • ◂◂RSS
  • Contact