Make cache expiration in work and bookmark controllers configurable

Description

We want to use an ArchiveConfig variable where we set the cache expiration on the latest works page, the latest bookmarks page, and certain work indexes. We’ll initially set the value to 30 minutes.

It’s important to note that the caching only applies to those certain work indexes if they are un-updated. Posting, deleting, or adding a chapter to those indexes will expire the cache, so logged in users will see the pages updated fairly quickly. Due to full page caching, logged out users will not see updates for 40 minutes.

Because we are not touching the cache expiration code, we can only do limited testing of this.

How to test:

First, it is important to note the “Turn on caching (currently experimental)” admin setting is enabled.

For the latest works page:

  • Log in

  • Go to the latest works page at https://test.ao3.org/works to ensure it gets placed in the cache

  • Post a work

  • Refresh the latest works page and confirm the new work hasn’t appeared

  • Wait 30 minutes

  • Refresh the latest works page and confirm the new work has appeared

For the latest bookmarks page:

  • Log in

  • Go to the latest bookmarks page at https://test.ao3.org/bookmarks to ensure it gets placed in the cache

  • Bookmark a work

  • Refresh the latest bookmarks page and confirm the new bookmark hasn’t appeared

  • Wait 30 minutes

  • Refresh the latest bookmarks page and confirm the new work has appeared

For the work indexes:

Activity

Show:
Sarken
December 6, 2019, 7:14 AM
Edited

Updated the issue!

Sarken
December 7, 2019, 4:10 AM
  • Logged in and out, I went to the latest works page, the Testing tag page, and testy's pseud's works page

  • As testy, I posted new work tagged Testing at 22:21 local

  • Logged in as testy, I checked all three pages again at 22:23. The work was on all three pages.

  • Logged out, I checked all three pages at 22:24. The work was not there.

  • Still logged out, I checked the three pages again at 22:56, and the work was still not there.

  • Again, still logged out, I checked all three pages at at 23:06, and the work was finally there.

This is consistent with production.

I am pretty sure what actually happens here is posting a work expires the cache, which is why logged in users see the changes almost immediately. However, because we cache full pages for logged out users for about 40 minutes, you don't see the change there for 40 minutes.

 

james_
December 8, 2019, 8:56 AM

For the latest works page:

For the latest bookmarks page:

For the work indexes:

https://test.archiveofourown.org/users/testy/pseuds/testy/works appeared to be updated but I don’t think it was in the cache to tried again all ok

Checking https://test.archiveofourown.org/users/testy/works again

posted https://test.archiveofourown.org/works/115

  • Wait 30 minutes

  • Refresh the work index again and confirm the new work has appeared

 

james_
December 8, 2019, 9:14 AM

The works turned up what seemed to me a few minutes early but I or someone else could have primed the cache earlier than I thought

 

Happy enough

 

Rebecca Sentance
December 8, 2019, 2:50 PM

Followed all the steps as outlined for works (after verifying that the setting was enabled on admin) and it worked as expected. I posted a new work to the Testy fandom https://test.archiveofourown.org/works/116 which didn’t show up initially, but then appeared after 30 minutes. I didn’t compare the work counts logged in vs. logged out.

DeployedToBeta

Assignee

james_

Reporter

james_

Roadmap

Bookmarks
Works

Priority

Medium

Affects versions

Fix versions

Components

Caching

Difficulty

Medium

Milestone

Internal 0.9
Configure