Shared cache for user-independent pages: decorator, user-read guard, audit tooling
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 28/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Active
- Domain
- backend, testing-qa
Research direction
Start with the design notes in #1360 and #695, then inspect library/django_utils/, the annotation-version switch, and the vg command entry point to understand the existing cache and tooling patterns. Trace user reads through views, templates, and template tags, including uicore/templatetags/ui_utils.py and ui_tabs_builder.py. Done means a shared cache can safely reject user-dependent responses, audit tooling can report user reads, and tests cover cross-user reuse and build-specific keys.
Written by the indexing model from the issue text.
Description
🤖 Written by Claude
Follow-on from #2007 (menus and the rest of the per-user page frame now load by ajax, so uicore/page/base.html reads nothing about the user) and the design notes on #1360 and #695. Those two issues are about public pages for anonymous users; this one is the infrastructure that lets a logged-in page whose body is user-independent be served from one shared cache entry.
Why cache_page can't do it. Django's LoginRequiredMiddleware evaluates request.user.is_authenticated before the view runs, which reads the session, and SessionMiddleware then adds Vary: Cookie. cache_page keys on the Vary headers, so on any login-required page it caches per session. Sharing across users needs an explicit key that ignores Vary, plus proof that the body is user-independent. That proof is the hard part: of the 96 templates extending base.html, 52 still read the user, and views reference request.user in some 620 places.
Proposed
shared_page_cache(key_fn, timeout)inlibrary/django_utils/: explicit key (path, genome build, a bumpable version counter), ignoresVary. During the view it wrapsrequest.userin a recording proxy and refuses to store, with a log line, if the view or its templates read the user. ("Session accessed" is no longer a usable signal because the middleware has already evaluated the lazy user.)- A version counter in Redis bumped by the annotation-version switch, with a management command to bump it by hand; a warmer task for the top-N objects by hit count is optional.
vg page <url> --user-reads: lists where the view and templates read the user, so auditing a candidate page is mechanical.uicore/templatetags/ui_utils.pyandui_tabs_builder.pyreadrequest.userfor admin-only tags, so the report has to cover template tags too.- First candidates whose bodies are already user-free or nearly so: view_gene_symbol (its annotation description already passes
user=Noneso it can be cached globally), transcript and gene version pages, ontology term pages, the annotation versions and evidence keys reference pages. Per-user sections become ajax fragments, which is the same porting #1360 needs. - Pages that stay user-specific keep
cache_page+vary_on_cookiewhere a per-session cache is still a win (analysis/views/views_grid.pyalready does this).
Fragment caching (#2654) is the cheaper first step and should land first; this issue is for the pages where the whole body can be shared. #1360 is this issue's first consumer for anonymous users.
Tests worth keeping: the decorator refuses a response whose view read the user; two requests for one path from different users hit the cache once; one path on two builds is two entries.
- Dominant language
- Python
- Stars
- 31
- Forks
- 4
- Avg merge
- 4h 52m
- Merged PRs (30d)
- 183
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from SACGF/variantgrid
-
Difficulty 2/5 1-3 hours Newbie friendliness 69/100
SACGF/variantgrid#2964 · 1 comment ·
Maintainers usually reply within 1 day
-
Genome build now duplicated in "imported as" on allele pagePossibly taken @TheMadBug claimed this 3 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
SACGF/variantgrid#2950 · 1 comment · 1 assignee ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
SACGF/variantgrid#2865 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
SACGF/variantgrid#2647 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
SACGF/variantgrid#2341 · 3 comments ·
Maintainers usually reply within 1 day
All issues in SACGF/variantgrid
Similar issues
-
Test: to_hijri() accepts datetime.datetime and uses only the date partPossibly taken A pull request linked to this issue is open or already merged. Opengood first issue
Difficulty 1/5 Under an hour Newbie friendliness 95/100
omarelshamy25x/shamy-hijri#63 · 3 comments ·
Maintainers usually reply within 1 day
-
polish
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
521xueweihan/HelloGitHub#4729 ·
-
[Bug]: Score parser reads parts of scientific notation as valid scoresPossibly taken @AshutoshSingh840 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
UKGovernmentBEIS/control-arena#992 ·
Maintainers usually reply within 3 days
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
mvalentsev/awesome-free-ai-coding#70 ·
Maintainers usually reply within 1 day