Refined-github: Cache not invalidates

Created on 22 Jul 2020  Â·  5Comments  Â·  Source: sindresorhus/refined-github

Descriptiion

on my setup the cache not invalidates correct.

symptom i faced

this results in some "errors" because of stale cache:

  • #3324 Bug at "Shows PRs that touch the current file."?
  • #3301 Feature Request: on an 404 with master try to redirect to main
  • show-associated-branch-prs-on-fork shows old data after 2 days

Suggested: page refresh

source https://github.com/sindresorhus/refined-github/issues/3302#issuecomment-662129283

 maxAge: 1 / 2, 
 staleWhileRevalidate: 4, 

staleWhileRevalidate means that you'll see cached data for 4 days after it expires (half a day), but one more page refresh will show the latest information.

i have done the page reload (⌘+r) and hard reload (⌘+⇧+r) many times before i reported an issue here.

How can i help

  • is there a way to track this problem?
  • how can i help to find the cause of the cache problem?
bug

All 5 comments

Please stop opening more issues about the cache.

I just verified that it works exactly as expected:

  • I had bugs-tab with this cached data: { data: 20, maxAge: 1595771254270 }
  • That maxAge is in 4 days and 13 minutes (bugs-tab is set to expire in 30 minutes + 4 days)
  1. I waited those 13 minutes
  2. I refreshed this page
  3. The tab still reported 20 because of the staleWhileRevalidate behavior
  4. I refreshed this page
  5. The tab reported 21 and the cached object was { data: 21, maxAge: 1595773212201 }, which is 4 days and 28 minutes

thanks for your patience and pointing me to the direction that i can check it myself.

1) break point

i found the cached data while creating a breakpoint in sources tab on refined-github.js at point const cachedItem = storageData[internalKey]; which would be here:

https://github.com/fregante/webext-storage-cache/blob/master/index.ts#L135

is this the only way i see the cached data? i don't find it in the dev-tools at Application/Cache/Cache Storage and not in Local Storage

2) refresh page

i understand it right that i have to do 2 normal page refreshs (⌘+r) before i get fresh data?

  1. Run await browser.storage.local.get() in the extension console context
  2. Yes. The first load after the expiration date will show the cached data, but also trigger the API request which updates the cache. The second load will use this new cache.

@muescha did you set the token? Is it still valid? Any errors in the console?

You may be pleased to know that I found an invalidation bug (https://github.com/fregante/webext-storage-cache/issues/21), but it only fails when the token is missing: https://github.com/sindresorhus/refined-github/issues/3340#issuecomment-663107083

the token is set in plugin:

Token in Plugin

and it seems to be used (in last week - no more detailed info is there):

Token

Setup with this permissions only:

Permissions

the console is filtered for refined and show this:
(i cutoff last line which says: s/refined-github? =12345 example number - i don't know if its a sensitive number)
Console

and this:

Bildschirmfoto 2020-07-23 um 22 46 28

Was this page helpful?
0 / 5 - 0 ratings

Related issues

juliocanares picture juliocanares  Â·  3Comments

yakov116 picture yakov116  Â·  3Comments

fregante picture fregante  Â·  3Comments

hkdobrev picture hkdobrev  Â·  3Comments

MilesBHuff picture MilesBHuff  Â·  3Comments