alaveteli icon indicating copy to clipboard operation
alaveteli copied to clipboard

Review different caching layers in Alaveteli with an eye to simplifying

Open crowbot opened this issue 11 years ago • 16 comments

We are caching in several places in the codebase. It would be good to do a review and see if there's an opportunity to simplify. Should also research what recommendations for caching in Rails 3/4 are.

crowbot avatar Jul 22 '13 15:07 crowbot

This is a precursor to https://github.com/mysociety/alaveteli/issues/1475

crowbot avatar May 20 '14 14:05 crowbot

Specifically, it would be good to decide if we've going to turn on Varnish purging again for WDTK or take some other strategy for expiring cached pages.

crowbot avatar May 23 '14 11:05 crowbot

A WhatDoTheyKnow user today was surprised by the site's caching practice. I think they may have seen changes a day before while logged in, then were surprised not to have seen them when viewing the site while not logged in the next day. They wrote:

I have just loaded up your website and, weirdly, all the corrections you made yesterday for me have reverted back to the incorrect and accurate versions.

RichardTaylor avatar Oct 03 '19 12:10 RichardTaylor

Adding a link led to confusion for me as it didn't immediately appear on the request page for a non-logged in user. Adding cache busting parameters to the URL (adding eg. ?odmflsd=dsnfnds) made the links appear. Slow caches / caches which don't update as the content update are surprising and confusing.

– https://github.com/mysociety/alaveteli/issues/5483#issuecomment-706341250

garethrees avatar Oct 12 '20 08:10 garethrees

Linking to https://github.com/mysociety/alaveteli/issues/1168

garethrees avatar Dec 03 '20 09:12 garethrees

I can't find the idea of a cache refreshing button for admins to use on pages/documents I recall that has been discussed. I think it might be a good idea, but better would be designing the system so it wasn't needed.

Cache delays do cause issues when running the site, admin actions aren't immediately reflected on the version of the site seen by non logged in users. We can:

  • confuse correspondents by saying we've done something but it appears we haven't
  • get reports of issues we've already dealt with
  • have to add complexity to messages explaining action has been taken but might take a long time to fully take effect

I also just made a mistake when I wrote a tweet which was intended to point to a newly updated public body page, but I forgot about the slow caching issue, so readers were initially sent to the old version of the page, and deleted and re-issued the tweet with a cache busting parameter.

RichardTaylor avatar Jun 23 '21 18:06 RichardTaylor

I had an issue I'd not experienced before this morning. I was creating censor rules and reloading a PDF to seek to see their effect. The PDF was being cached and I had to add URL parameters to break thought the cache.

Previously reloading / re-downloading a PDF has been sufficient to obtain the latest copy.

I don't yet know if this was an issue with one document or if it is a general issue.

RichardTaylor avatar Aug 02 '21 11:08 RichardTaylor

I don't yet know if this was an issue with one document or if it is a general issue.

I am now doing other redactions and seeing the effects straight away as usual.

RichardTaylor avatar Aug 02 '21 16:08 RichardTaylor

While we've now reduced the attachment cache usage in https://github.com/mysociety/alaveteli/issues/1549, it still grows pretty large, especially since mySociety hosts several Alavetelis.

We should probably use ActiveStorage with a S3 compatible backend so that we have more flexibility in how we distribute these files.

garethrees avatar Sep 06 '21 09:09 garethrees

Yes, and also get this enabled for raw_emails, files and other things, too. We'd need to consider the prioritisation for each area carefully.

sagepe avatar Sep 08 '21 08:09 sagepe

This thread has previously been linked to #1168 "Requests not appearing immediately on request list page" but just to expand on that - sometimes what looks like it might be a caching issue will actually be a slow search index updating issue.

RichardTaylor avatar Sep 14 '21 15:09 RichardTaylor

https://blog.polyhaven.com/how-we-handle-80tb-and-5m-page-views-a-month-for-under-400/

garethrees avatar Jan 07 '22 11:01 garethrees

At WhatDoTheyKnow we wanted to tweet a link to a page on which we had just added an annotation.

We had an inkling that we needed to be aware caching could delay the appearance of the annotation to non-logged in users.

Our experience is shown below, comments from three people in different places taken from Slack:

Just waiting for the annotation [...] to appear from the point of view of non logged in users

It shows up for me logged out and in incognito mode.

It didn't show up for me in incognito mode, I had to add ?no-cache . Not even with Ctrl + F5. (edited)

I didn't need to do that at all. Odd. Could be an ISP thing?

It was inconsistent for me too. I could see the annotation via curl and safari new private window. Couldn't see it when logged out in a normal Safari window. All on the same computer.

I can't see it on my phone, either on WiFi or 4G. And I don't believe I've previously loaded the page on my phone.

visible on my phone on wifi, not visible on my phone on 4g. (A reload after switching to 4g made the annotation disappear)

It works for me wherever I try & via [ISP] or 4g

RichardTaylor avatar Jun 09 '22 17:06 RichardTaylor

At the time of writing @confirmordeny and I are both currently experiencing

https://www.whatdotheyknow.com/body/list/estate_management_scheme

not being updated with changes (additions to the list) made around 12 hours ago

RichardTaylor avatar Oct 14 '22 21:10 RichardTaylor

All slow cache issues are being closed in-favour of this issue; however this issue relates to a systematic change and often the issue is that cache-updates appear surprisingly slow at the moment / recently / on a specific page.

RichardTaylor avatar Oct 14 '22 21:10 RichardTaylor

All slow cache issues are being closed in-favour of this issue…

The underlying causes are likely to be the same (or if they're different, we won't really know until we've got a much clearer understanding of how all the layers interact).

garethrees avatar Oct 17 '22 09:10 garethrees

Should look at what our etags are doing and how they interact with varnish

garethrees avatar Aug 22 '23 09:08 garethrees