New Feature: Allow Staff to clear Added Content cache

Bug #1435938 reported by Thomas Berezansky
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Evergreen
Fix Released
Wishlist
Unassigned

Bug Description

When staff update identifiers in records, or upstream providers update content, the ability to clear the previous cache entries would come in handy. The branch below adds a clearcache "type" to the Added Content Module. The "format" provided should either be "all" to clear all types or an Added Content type (such as "jacket" or "summary") to clear.

I wrapped AuthHandler blocks around the new clearcache URLs in Apache requiring STAFF_LOGIN to avoid unauthenticated use of the new feature.

I also put a simple link in the catalog when viewed in a staff context to clear the Added Content cache for the current record. From a purely utilitarian point of view the link works. From an end-user point of view we may want to change the wording, add an icon, move it to another location, etc. Adding a "just jacket images" link may also be desired, depending on what people see as use cases.

http://git.evergreen-ils.org/?p=working/Evergreen.git;a=shortlog;h=refs/heads/user/tsbere/addedcontent_clearcache

Changed in evergreen:
assignee: nobody → Josh Stompro (u-launchpad-stompro-org)
Revision history for this message
Josh Stompro (u-launchpad-stompro-org) wrote :

Tested on SB1 using record 45(The piano concertos., Chopin) which already has some jacket art. Loaded the record in the opac and viewed the small/medium/large versions of the jacket to get them all loaded into memcached. There is no large jacket art for that record... just noticed.

Changed the ISBN to something else with different jacket art. Tested to make sure the orig covers will still displaying from memcached, they were.

Clicked on the "Clear AddedContent Cache" link and saw the report that the medium and small cover art had been deleted.

Reloaded the record in the opac and saw the new jacket art. So it looks like it works just fine.

I tried on my own test system yesterday along with some other branches, including "#1449709 support caching of compiled Template Toolkit templates " and I couldn't get it to work. The cache just wasn't actually cleared when I ran it, so that might be something else for someone to test it against.

Josh

tags: added: signedoff
Changed in evergreen:
assignee: Josh Stompro (u-launchpad-stompro-org) → nobody
Revision history for this message
Josh Stompro (u-launchpad-stompro-org) wrote :

I have tested this code and consent to signing off on it with my name, Josh Stompro and email address, <email address hidden>.

Revision history for this message
Josh Stompro (u-launchpad-stompro-org) wrote :

Dang, I found an issue after I kept poking at my other test system. I think that the apache config needs to set a nocache option for the clearcache url. When I try to clear a record the second time, I just get the cached results from the first run. When I tested on the sandbox I only tested once, I didn't try it a second time.

When I modify my apache config for the clearcache location and enable mod_headers it works correctly every time.

<Location /opac/extras/ac/clearcache/>
    PerlAccessHandler OpenILS::WWW::AccessHandler
    PerlSetVar OILSAccessHandlerPermission "STAFF_LOGIN"
    <IfModule mod_headers.c>
        Header onsuccess set Cache-Control no-cache
    </IfModule>
</Location>

Now the response header always includes Cache-Control: no-cache

So I think some more testing is needed. mod_headers is not currently enabled by default in Jessie, should it be? Removing my signoff tag until someone else can take a look at this.

tags: removed: signedoff
Revision history for this message
Thomas Berezansky (tsbere) wrote :

I added a $r->no_cache(1); to the "clear the cache" response. This causes mod_perl to set:

  Pragma: no-cache
  Cache-control: no-cache

In quick testing this appears to be sufficient to deal with the "clear cache response was cached" issue.

The branch above has been updated with the new commit.

Revision history for this message
Josh Stompro (u-launchpad-stompro-org) wrote :

I just tested again on SB1 and here is how I can replicate the issue.

1. Visit a record in the staff client that has jacket art.
2. Click the Clear AddedContent Cache, note which items were cleared, probably TOC and Medium.
3. In a browser load the small jacket art for that record, like http://sb1.missourievergreen.org/opac/extras/ac/jacket/small/r/45
4. Back in the staff client, click the "Clear AddedContent Cache" button again, and observe that you get the exact same results as the first time, even though the only data in the cache is for the small jacket art.
5. Clear the staff client cache, Admin -> for Developer -> clear cache.
6. Click the "Clear addedcontent cache" button again and see that only the small jacket art is cleared.

For normal usage this isn't probably a big deal, you only need to clear the cache once probably, but it does make testing confusing.

Josh

Revision history for this message
Thomas Berezansky (tsbere) wrote :

That....sounds like you are missing the latest commit I pushed. Did you "git fetch --all" or at least "git fetch working" (or whatever your working remote is named) to get the updated code before this test?

Revision history for this message
Josh Stompro (u-launchpad-stompro-org) wrote :

Thomas, sorry I didn't see your message before I tested this last time. I'll re-test with your new patch when I have a chance.
Josh

Revision history for this message
Josh Stompro (u-launchpad-stompro-org) wrote :

I tested with new patch on another sandbox provided by Kathy and it worked great. The clearcache page was never cached and worked every time.

I have tested this code and consent to signing off on it with my name, Josh Stompro and email address, <email address hidden>.

Changed in evergreen:
status: New → Confirmed
tags: added: signedoff
Revision history for this message
Ben Shum (bshum) wrote :

Looks like an awesome new feature! I'm going to set the target for this towards 2.9. This needs a quick release note, etc. to go with it prior to final merge.

Changed in evergreen:
importance: Undecided → Wishlist
milestone: 2.next → 2.9-alpha
Changed in evergreen:
milestone: 2.9-alpha → 2.9-beta
Revision history for this message
Ben Shum (bshum) wrote :

Okay I added a release note as I merged the branch to master for inclusion.

Whoot, whoot for this feature!

Changed in evergreen:
status: Confirmed → Fix Committed
Changed in evergreen:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.