Skip to content
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

Move the service worker (or its scope), so that it catches all the request from the iframe, and not the ones from the UI #138

Closed
mossroy opened this issue Jan 6, 2016 · 4 comments
Assignees
Milestone

Comments

@mossroy
Copy link
Contributor

mossroy commented Jan 6, 2016

It's a blocker for some ZIM files (for example wikipedia_fr_all_09_2012.zim), which use absolute URLs like /A/Article.html.
And the service-worker.js file should be placed with the other javascript files (if possible)

@mossroy mossroy self-assigned this Jan 6, 2016
@mossroy mossroy added this to the v2.0 milestone Jan 6, 2016
@mossroy mossroy changed the title Move the service worker (or its scope), so that it does not try to catch the CSS/JS files of the UI Move the service worker (or its scope), so that it catches all the request from the iframe, and not the ones from the UI Jan 8, 2016
@mossroy mossroy added bug and removed enhancement labels Jan 8, 2016
@mossroy
Copy link
Contributor Author

mossroy commented Jan 8, 2016

@kelson42 tells me that the norm is now to have relative URLs everywhere (since the end of 2014).
So this issue is not crucial, but it would be much cleaner.

@mossroy mossroy modified the milestones: v2.1, v2.0 Apr 29, 2016
@mossroy mossroy modified the milestones: v2.3, v2.2 Jul 25, 2017
@mossroy mossroy modified the milestones: v2.4, v2.5 Sep 22, 2018
@mossroy mossroy modified the milestones: v2.5, v2.6 Jan 9, 2019
@mossroy mossroy modified the milestones: v2.6, v2.7 Jul 14, 2019
@kelson42
Copy link
Collaborator

kelson42 commented Feb 2, 2020

I would not recommend to handle cases which are not respecting the ZIM specification. That only makes the code more complicated.... for no added value. I strongly recommend to close this ticket as wont-fix.

@mossroy
Copy link
Contributor Author

mossroy commented Feb 3, 2020

No.
The goal here is not to handle faulty ZIM files, but to make the ServiceWorker only handle what it should handle.
Currently, it technically catches ALL the HTTP requests made by the browser, including the ones to load the resource of kiwix-js itself (like fetching www/js/app.js).

There is a regular expression at the beginning of the ServiceWorker that checks if the URL matches a ZIM URL. It ignores the rest, so that everything works.

But it would be much better if we managed to make the ServiceWorker catch only the requests that come from the iframe.
Now that we implemented #534, we might catch only the URLs with our prefix.
The problem is that this prefix is the ZIM file name, which we do not know when the ServiceWorker is initialized.

A solution might be to change our prefix : instead of having only the ZIM file name, we might use something like "articleContent/" + zimFileName, and make the ServiceWorker catch only the URLs starting with "articleContent/"
This should not be very difficult.

@mossroy mossroy added enhancement and removed bug labels Mar 4, 2020
@mossroy mossroy modified the milestones: v2.7, v2.8 Mar 29, 2020
@mossroy mossroy modified the milestones: v2.8, v2.9 Jul 11, 2020
@Jaifroid Jaifroid modified the milestones: v3.0, v3.1 Oct 3, 2020
@Jaifroid Jaifroid modified the milestones: v3.1, v3.2 Dec 6, 2020
@mossroy mossroy modified the milestones: v3.2, v3.3 Aug 22, 2021
@mossroy
Copy link
Contributor Author

mossroy commented Dec 12, 2021

I close this issue as "won't fix" because #764 needs the ServiceWorker to catch all the requests (including the ones from the UI)

@mossroy mossroy closed this as completed Dec 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants