Skip to content

Remove custom web-forms caching by key, defer to workbox pwa #2696

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

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

spwoodcock
Copy link
Member

What type of PR is this? (check all applicable)

  • πŸ• Feature
  • πŸ› Bug Fix
  • πŸ“ Documentation
  • πŸ§‘β€πŸ’» Refactor
  • βœ… Test
  • πŸ€– Build or CI
  • ❓ Other (please specify)

Related Issue

Looking into this during #2674

Describe this PR

  • We implemented a custom caching mechanism for webforms, to avoid loading every time a feature is clicked.
  • Since then, we added workbox runtime caching.
  • Ideally the webforms can be cached as part of the PWA workbox config.
  • If you think it's feasible, could you please continue this @DanielJDufour πŸ™?
  • If not, we can close and keep caching manually - but we need a way to avoid the cache conflicts that keep occurring (perhaps we need a rule to omit this path in workbox too).

Checklist before requesting a review

[optional] What gif best describes this PR or how it makes you feel?

@spwoodcock spwoodcock added this to the (2025.4.1) PATCH Release milestone Jul 11, 2025
@spwoodcock spwoodcock requested a review from DanielJDufour July 11, 2025 16:59
@github-actions github-actions bot added bug Something isn't working frontend:mapper Related to the mapper frontend code labels Jul 11, 2025
@DanielJDufour
Copy link
Collaborator

Sure! I can take a look! I think the crux of it will be trying to find a way for the workbox cache to apply to the iframe's context. I'll try to think creatively, including maybe loading workbox inside the iframe. I'll know more once I dive in! Thanks for getting this started!

@DanielJDufour
Copy link
Collaborator

DanielJDufour commented Jul 20, 2025

I'm working on this currently. I think we want to look into pre-caching 'https://hotosm.github.io/web-forms/odk-web-form.js' and '/web-forms.html'.

For the things that depend on the config.json, which is dynamically loaded, I don't think we can technically do pre-caching in the service worker using a manifest. Instead, I'll look at trying to do "preemptive" (is that the right word?) runtime caching where we cache right when the project is loaded (and not waiting for a map feature to be selected). In other words, try to load the resources as soon as we can (after config.json loaded).

@spwoodcock
Copy link
Member Author

I'm working on this currently. I think we want to look into pre-caching 'https://hotosm.github.io/web-forms/odk-web-form.js' and '/web-forms.html'.

For the things that depend on the config.json, which is dynamically loaded, I don't think we can technically do pre-caching in the service worker using a manifest. Instead, I'll look at trying to do "preemptive" (is that the right word?) runtime caching where we cache right when the project is loaded (and not waiting for a map feature to be selected). In other words, try to load the resources as soon as we can (after config.json loaded).

Nice, sounds like a plan! Its likely the cache config in the vite config for the precaching πŸ˜ƒ

@spwoodcock
Copy link
Member Author

Hi @DanielJDufour!

We are finalising and deploying the MdP project for a demo / review around 29th July.
Do you think this issue might be solvable before then, or it's more complex? πŸ™

@DanielJDufour
Copy link
Collaborator

DanielJDufour commented Jul 22, 2025

@spwoodcock , yes. I think it's solvable. Worse case scenario is if I can't get the elegant vite.config.ts approach to work to precache the files in the service worker. I can just force an early runtime cache, by calling fetch on the resources when the app loads. I'll give myself to Wednesday to get the more elegant approach to work. If it doesn't work then, I can take the more hacky approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working frontend:mapper Related to the mapper frontend code
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

2 participants