-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
perf: Add config option enableResourceCache
to cache dashboard resources locally for faster loading in additional browser tabs
#2920
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I will reformat the title to use the proper commit message syntax. |
🚀 Thanks for opening this pull request! |
Warning Rate limit exceeded@mtrezza has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 8 minutes and 59 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughA browser service worker feature was introduced to the dashboard. This includes a new configuration option to enable or disable the service worker, updates to HTML responses to expose this setting, a new service worker script for asset caching, client-side logic for registration and lifecycle management, and corresponding documentation in the README. Changes
Sequence Diagram(s)sequenceDiagram
participant Browser
participant Dashboard_HTML
participant registerServiceWorker.js
participant ServiceWorker (sw.js)
participant Server
Browser->>Server: Request /login or /*
Server-->>Browser: Responds with HTML (includes PARSE_DASHBOARD_ENABLE_RESOURCE_CACHE)
Browser->>Dashboard_HTML: Loads and renders dashboard
Dashboard_HTML->>registerServiceWorker.js: Call registerServiceWorker()
alt Resource cache enabled and supported
registerServiceWorker.js->>Browser: Increment open tab count (localStorage)
Browser->>ServiceWorker (sw.js): Register service worker (on window load)
ServiceWorker (sw.js)-->>Browser: Service worker installed and activated
Browser->>ServiceWorker (sw.js): Asset fetch requests (script/style/bundles)
ServiceWorker (sw.js)-->>Browser: Serve from cache or fetch & cache
Browser->>registerServiceWorker.js: On beforeunload/pagehide
registerServiceWorker.js->>Browser: Decrement open tab count
alt Last tab closed
registerServiceWorker.js->>ServiceWorker (sw.js): Post 'unregister' message
ServiceWorker (sw.js)->>Browser: Unregister self
registerServiceWorker.js->>Browser: Unregister service worker, clear caches
end
else Resource cache disabled or unsupported
registerServiceWorker.js-->>Browser: Exit, do nothing
end
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
The label |
🎉 Snyk checks have passed. No issues have been found so far.✅ security/snyk check is complete. No issues have been found. (View Details) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🧹 Nitpick comments (3)
src/registerServiceWorker.js (1)
5-10
: Consider adding error logging for service worker registration failuresWhile the service worker registration logic is correct, silently catching all errors might hide important registration failures that could help with debugging.
Consider adding minimal logging:
- navigator.serviceWorker.register(swPath).catch(() => {}); + navigator.serviceWorker.register(swPath).catch((error) => { + console.warn('Service worker registration failed:', error); + });Parse-Dashboard/public/sw.js (2)
9-9
: Consider more robust resource filteringThe current filtering logic is functional but could be more robust and explicit about what resources should be cached.
Consider using URL patterns for clearer intent:
- if (req.destination === 'script' || req.destination === 'style' || req.url.includes('/bundles/')) { + const shouldCache = req.destination === 'script' || + req.destination === 'style' || + req.url.includes('/bundles/') || + req.url.match(/\.(js|css)$/); + if (shouldCache) {
1-1
: Consider implementing cache versioning strategyThe hardcoded cache name 'dashboard-cache-v1' should be updated when dashboard assets change to ensure users get fresh content.
Consider implementing a build-time cache versioning strategy:
- Generate cache names based on build hash/timestamp
- Update cache names when assets change
- This ensures proper cache invalidation for new deployments
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
Parse-Dashboard/app.js
(2 hunks)Parse-Dashboard/parse-dashboard-config.json
(1 hunks)Parse-Dashboard/public/sw.js
(1 hunks)README.md
(2 hunks)src/dashboard/index.js
(1 hunks)src/login/index.js
(1 hunks)src/registerServiceWorker.js
(1 hunks)
🧰 Additional context used
🧠 Learnings (2)
Parse-Dashboard/app.js (2)
Learnt from: mtrezza
PR: parse-community/parse-dashboard#0
File: :0-0
Timestamp: 2025-05-11T16:43:27.354Z
Learning: The bcryptjs library is used in Parse Dashboard for password encryption and validation in three files: Parse-Dashboard/Authentication.js (compareSync), Parse-Dashboard/CLI/mfa.js (genSaltSync, hashSync), and src/dashboard/Settings/DashboardSettings/DashboardSettings.react.js (genSaltSync, hashSync).
Learnt from: mtrezza
PR: parse-community/parse-dashboard#2828
File: src/dashboard/Data/Browser/Browser.react.js:1605-1607
Timestamp: 2025-05-27T12:09:47.644Z
Learning: In script execution dialogs in Parse Dashboard (specifically the `confirmExecuteScriptRows` method in `src/dashboard/Data/Browser/Browser.react.js`), individual `setState` calls to update `processedScripts` counter should be kept as-is rather than batched, because this provides real-time progress feedback to users in the dialog UI.
README.md (1)
Learnt from: mtrezza
PR: parse-community/parse-dashboard#0
File: :0-0
Timestamp: 2025-05-11T16:43:27.354Z
Learning: The bcryptjs library is used in Parse Dashboard for password encryption and validation in three files: Parse-Dashboard/Authentication.js (compareSync), Parse-Dashboard/CLI/mfa.js (genSaltSync, hashSync), and src/dashboard/Settings/DashboardSettings/DashboardSettings.react.js (genSaltSync, hashSync).
🧬 Code Graph Analysis (1)
src/login/index.js (3)
src/dashboard/index.js (1)
path
(21-21)src/login/Login.js (1)
Login
(14-135)src/registerServiceWorker.js (1)
registerServiceWorker
(1-11)
🔇 Additional comments (10)
Parse-Dashboard/parse-dashboard-config.json (1)
13-14
: LGTM! Configuration option properly added.The new
enableBrowserServiceWorker
option is correctly positioned and defaults tofalse
, which is appropriate for an opt-in performance feature.src/login/index.js (2)
11-11
: LGTM! Service worker registration properly imported.The import statement correctly references the service worker registration module.
19-19
: LGTM! Service worker registration properly invoked.The service worker registration is called after the React component is rendered, ensuring proper initialization timing.
src/dashboard/index.js (2)
15-15
: LGTM! Service worker registration properly imported.The import statement correctly references the service worker registration module, consistent with the login entry point.
23-23
: LGTM! Service worker registration properly invoked.The service worker registration is called after the React component is rendered, ensuring proper initialization timing and consistency across entry points.
Parse-Dashboard/app.js (2)
222-224
: LGTM! Service worker configuration properly injected in login route.The global variable
PARSE_DASHBOARD_ENABLE_SERVICE_WORKER
is correctly injected based on the server configuration, following the same pattern as the existingPARSE_DASHBOARD_PATH
variable.
257-259
: LGTM! Service worker configuration properly injected in dashboard route.The global variable injection is consistent with the login route implementation, ensuring the service worker registration can access the configuration flag.
README.md (2)
46-46
: LGTM! Table of contents properly updated.The new "Browser Service Worker" section is correctly added to the table of contents under "Other Configuration Options".
514-533
: LGTM! Service worker feature properly documented.The documentation clearly explains the feature's purpose, provides a complete configuration example, and properly notes that the feature is disabled by default. The explanation is concise and helpful for users.
src/registerServiceWorker.js (1)
1-4
: LGTM: Clean feature flag implementationThe early return pattern with the feature flag is well-implemented and follows good practices for conditional functionality.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
README.md (2)
41-47
: Preserve alphabetical order in the options indexThe sub-index under Other Configuration Options had been alphabetically ordered.
Inserting “Resource Cache” after “Scripts” breaks that convention and makes the list harder to scan.Diff-ready fix:
- - [Scripts](#scripts) - - [Resource Cache](#resource-cache) + - [Resource Cache](#resource-cache) + - [Scripts](#scripts)
539-544
: Adopt GitHub-friendly admonition syntax & remove blank line inside blockquote
> [!Warning]
/> [!Note]
is not rendered specially on GitHub and also triggers MD028.
Use a standard blockquote with an emoji or bold heading and keep it contiguous.-> [!Warning] -> This feature can make it more difficult ... +> ⚠️ **Warning:** +> This feature can make it more difficult ... -> [!Note] -> For developers: during dashboard development ... +> 💡 **Note for developers:** +> During dashboard development ...No blank line between the
>
lines keeps markdownlint quiet.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
Parse-Dashboard/app.js
(2 hunks)README.md
(2 hunks)src/registerServiceWorker.js
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- Parse-Dashboard/app.js
- src/registerServiceWorker.js
🧰 Additional context used
🧠 Learnings (1)
README.md (1)
Learnt from: mtrezza
PR: parse-community/parse-dashboard#0
File: :0-0
Timestamp: 2025-05-11T16:43:27.354Z
Learning: The bcryptjs library is used in Parse Dashboard for password encryption and validation in three files: Parse-Dashboard/Authentication.js (compareSync), Parse-Dashboard/CLI/mfa.js (genSaltSync, hashSync), and src/dashboard/Settings/DashboardSettings/DashboardSettings.react.js (genSaltSync, hashSync).
🪛 markdownlint-cli2 (0.17.2)
README.md
541-541: Blank line inside blockquote
(MD028, no-blanks-blockquote)
🔇 Additional comments (1)
README.md (1)
518-536
: Double-check naming consistency with implementationDocumentation refers to the option as
enableResourceCache
, but the PR summary mentions
enableBrowserServiceWorker
and an env-varPARSE_DASHBOARD_ENABLE_RESOURCE_CACHE
.Please verify the actual public API to avoid confusing users and breaking existing configs.
Typical places to cross-check:
• constructor-level option name (new ParseDashboard({ … })
)
• JSON config file property
• environment variable mappingIf the code uses a different identifier, update either the docs or the code before merging.
enableResourceCache
to cache dashboard resource in browser for faster loading in additional browser tabs
enableResourceCache
to cache dashboard resource in browser for faster loading in additional browser tabsenableResourceCache
to cache dashboard resources locally for faster loading in additional browser tabs
# [7.3.0-alpha.21](7.3.0-alpha.20...7.3.0-alpha.21) (2025-07-18) ### Performance Improvements * Add config option `enableResourceCache` to cache dashboard resources locally for faster loading in additional browser tabs ([#2920](#2920)) ([41a4963](41a4963))
🎉 This change has been released in version 7.3.0-alpha.21 |
# [7.3.0](7.2.1...7.3.0) (2025-08-01) ### Bug Fixes * Changing "Relative dates" option of saved filter does not enable save button ([#2947](#2947)) ([4f4977d](4f4977d)) * Class object counters in sidebar not updating ([#2950](#2950)) ([0f1920b](0f1920b)) * Clicking linked pointer with Cmd key in view table doesn't open page in new browser tab ([#2902](#2902)) ([101b194](101b194)) * Fails to generate MFA code with CLI command `parse-dashboard --createMFA` ([#2883](#2883)) ([544df1f](544df1f)) * Gracefully fail when trying to get new features in latest version of dashboard ([#2880](#2880)) ([1969a0e](1969a0e)) * Header checkbox in data browser does not indicate when a few rows are selected ([#2957](#2957)) ([e4ab666](e4ab666)) * Hyperlink in Views table ignores `urlQuery` key ([#2926](#2926)) ([c5eedf4](c5eedf4)) * Incorrect table cell width in App Settings table ([#2933](#2933)) ([d46765b](d46765b)) * Info panel scroll-to-top setting not persistent across dashboard sessions ([#2938](#2938)) ([2b78087](2b78087)) * Invalid clipboard content for multi-cell copy in data browser ([#2882](#2882)) ([22a2065](22a2065)) * Legacy filters without `filterId` cannot be deleted in data browser ([#2946](#2946)) ([65df9d6](65df9d6)) * Legacy filters without `filterId` do not appear in sidebar ([#2945](#2945)) ([fde3769](fde3769)) * Modal text input can be resized smaller than its cell in Safari browser ([#2930](#2930)) ([82a0cdc](82a0cdc)) * Move settings button on data browser toolbar for better UI ([#2940](#2940)) ([c473ce6](c473ce6)) * Pagination footer bar hides rows in data browser ([#2879](#2879)) ([6bc2da8](6bc2da8)) * Race condition on info panel request shows info panel data not corresponding to selected cell ([#2909](#2909)) ([6f45bb3](6f45bb3)) * Saved legacy filter in data browser cannot be deleted or cloned ([#2944](#2944)) ([15da90d](15da90d)) * Saved legacy filter with classname in query cannot be deleted ([#2948](#2948)) ([05ee5b3](05ee5b3)) * Selected text in info panel cannot be copied using Ctrl+C ([#2951](#2951)) ([0164c19](0164c19)) * Views not sorted alphabetically in sidebar ([#2943](#2943)) ([4c81fe4](4c81fe4)) * Warning dialog is shown after executing script on selected rows ([#2899](#2899)) ([027f1ed](027f1ed)) ### Features * Add additional values in info panel key-value element ([#2904](#2904)) ([a8f110e](a8f110e)) * Add AI agent for natural language interaction with Parse Server ([#2954](#2954)) ([32bd6e8](32bd6e8)) * Add clipboard icon to copy value of key-value element in info panel ([#2871](#2871)) ([7862c42](7862c42)) * Add Cloud Function as data source for views with optional text or file upload ([#2939](#2939)) ([f5831c7](f5831c7)) * Add column freezing in data browser ([#2877](#2877)) ([29f4a88](29f4a88)) * Add custom data views with aggregation query ([#2888](#2888)) ([b1679db](b1679db)) * Add environment variable support for AI agent configuration ([#2956](#2956)) ([2ac9e7e](2ac9e7e)) * Add hyperlink support in Views table ([#2925](#2925)) ([06cfc11](06cfc11)) * Add inclusive date filters "is on or after", "is on or before" in data browser ([#2929](#2929)) ([c8d621b](c8d621b)) * Add quick-add button to array parameter in Cloud Config ([#2866](#2866)) ([e98ccb2](e98ccb2)) * Add row number column to data browser ([#2878](#2878)) ([c0aa407](c0aa407)) * Add Settings menu to scroll info panel to top when browsing through rows ([#2937](#2937)) ([f339cb8](f339cb8)) * Add support for "not equal to" filter for Boolean values in data browser and analytics explorer ([#2914](#2914)) ([d55b89c](d55b89c)) * Add support for `Image` type in View table to display images ([#2952](#2952)) ([6a6b1f0](6a6b1f0)) * Add type mismatch warning when quick-adding entry to Cloud Config array parameter ([#2875](#2875)) ([bb1837f](bb1837f)) * Add view edit icon to views list in sidebar ([#2901](#2901)) ([96e33b9](96e33b9)) * Allow editing filter without loading data in data browser ([#2949](#2949)) ([9623580](9623580)) * Allow editing saved filters in data browser ([#2942](#2942)) ([daaccaa](daaccaa)) * Allow freeform text view resizing in modal dialogs ([#2910](#2910)) ([1399162](1399162)) * Persist info panel visibility when navigating across classes in data browser ([#2908](#2908)) ([1a3610a](1a3610a)) * Prefetch info panel data with config options `prefetchObjects` and `prefetchStale` ([#2915](#2915)) ([54a8156](54a8156)) * Warn when leaving data browser page with selected rows ([#2887](#2887)) ([206ead1](206ead1)) ### Performance Improvements * Add config option `enableResourceCache` to cache dashboard resources locally for faster loading in additional browser tabs ([#2920](#2920)) ([41a4963](41a4963))
Summary
Testing
npm test
npm run lint
https://chatgpt.com/codex/tasks/task_e_6878f529c7f0832db6628e25b01b9e02
Summary by CodeRabbit
New Features
Documentation