bfcneedsupdate() compares 'expires' by date, so short max-age resources are stale immediately after download
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 67/100
Direzione di ricerca
Start in R/BiocFileCache-class.R at the bfcneedsupdate() expiry check near line 1024, then inspect its tests for expiry and ETag/Last-Modified behavior. Reproduce with a resource whose max-age is shorter than the time until midnight; the fix is done when it is not marked stale immediately after download and the existing freshness checks still behave correctly.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Problem
bfcneedsupdate() checks expiry by calendar date:
https://github.com/Bioconductor/BiocFileCache/blob/devel/R/BiocFileCache-class.R#L1024
expired <- as.Date(file_expires, optional=TRUE) <= Sys.Date()
expires is set to response time + max-age (since #55). When max-age is shorter than the time left until midnight, the expiry date is today. The check is then TRUE immediately, and because expired short-circuits the ETag/Last-Modified comparison, the resource reports as stale right after download.
bioconductor.org now serves files through Cloudflare with short max-age values, so this affects most Bioconductor-hosted resources:
| URL | cache-control |
|---|---|
packages/stats/bioc/bioc_pkg_stats.tab |
max-age=300, s-maxage=3600 |
checkResults/devel/bioc-LATEST/BUILD_STATUS_DB.txt |
max-age=300, s-maxage=31536000 |
packages/3.23/bioc/VIEWS |
max-age=30, s-maxage=31536000 |
Reprex
BiocFileCache 3.2.0 (release); the same line is in devel 3.3.3.
library(BiocFileCache)
url <- "https://bioconductor.org/packages/stats/bioc/bioc_pkg_stats.tab"
bfc <- BiocFileCache(tempfile(), ask = FALSE)
bfcadd(bfc, rname = url, fpath = url, rtype = "web", action = "copy", download = TRUE)
rid <- bfcquery(bfc, url, "rname", exact = TRUE)$rid
bfcinfo(bfc, rid)$expires # a few minutes from now, i.e. today
bfcneedsupdate(bfc, rid) # TRUE, seconds after the download
Impact
Any package that does if (bfcneedsupdate(...)) bfcdownload(...) on these URLs re-downloads them on every call, so the cache does nothing. BiocPkgTools hit this as a test failure on r-universe (seandavi/BiocPkgTools#92) and worked around it in seandavi/BiocPkgTools#93 by doing its own size/ETag/Last-Modified check.
Suggested fix
Compare full timestamps instead of dates, e.g.
expired <- as.POSIXct(file_expires, tz = "GMT", optional = TRUE) <= Sys.time()
It would also be worth considering whether an expired entry should fall through to the ETag / Last-Modified check rather than returning TRUE outright. With max-age=30, a cache that has merely passed max-age is usually still current, and a matching ETag is stronger evidence than expiry.
- Lingua principale
- R
- Stelle
- 14
- Fork
- 9
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di Bioconductor/BiocFileCache
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
Bioconductor/BiocFileCache#76 · 1 commento ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
Bioconductor/BiocFileCache#72 · 3 commenti ·
-
Error in .util_downloadAperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 25/100
Bioconductor/BiocFileCache#66 · 16 commenti ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
Bioconductor/BiocFileCache#60 · 3 commenti ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 30/100
Tutte le issue di Bioconductor/BiocFileCache
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
HelenaLC/spatialdataR#295 ·
-
size-time-budget
Difficoltà 2/5 1-3 ore Idoneità per principianti 69/100
kapelner/EDI#66 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
Openscapes/blogscapes#61 ·
I maintainer di solito rispondono entro 1 giorno
-
bug posit-ai
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100