Repository navigation
Description
I'm submitting a...
[x] Bug report
[x] Feature request (not sure, maybe this is more a feature request?)
Current behavior
If you ng run app:build:production and your pwa comes with a <video> element where you also utilize seeking (setting currentTime depending on your app logic and/or user input) it will not work or only very inconsistently. Most videos will simply run from start and not at the setted currentTime position. This is only the case when videos are delivered/fetched by the service worker. So it works in development mode.
Expected behavior
Videos should start at the setted currentTime.
Minimal reproduction of the problem with instructions
// on template
<video id="myVideo"><source id="myVideoSrc" src="video.mp4" type="video/mp4"></video>
// in page.ts
let videoObject = document.getElementById("myVideo");
videoObject.currentTime = 100;
videoObject.play();
// now build for production
// @angular/pwa has to be installed
> ng run app:build:production
Environment
Angular version: 6.1.2
Browser:
Chrome (desktop) version 69
Others:
This seems to be a known problem since service workers don't know Range requests. However it also looks like very easily fixable if I understand this thread comment correctly: https://bugs.chromium.org/p/chromium/issues/detail?id=575357#c10
A workaround would be a convenient way to completely exclude requests from service worker (not just set strategies for them). But obviously it would be better if we also could cache some videos. For exclusion also this issue may be relevant : #21191
EDIT(gkalpak): Issue summary in #25865 (comment).
Activity
gkalpak commentedon Sep 17, 2018
Fixing #21191 would indeed provide a workaround for this usecase (but this could be properly fixable on its own as well).
Does anyone want to take a stub at incorporating this fix into
@angular/service-worker.mordka commentedon Nov 30, 2018
We hit this issue, because requests to video needed to be
withCredentialsand SW failed over without applying cookies to headers. A workaround was to skip handling request via SW. We used patch-package to maintain this patch. Here is the patchmarod424 commentedon Dec 10, 2018
@mordka Thank you for your suggested fix.
I was having a slightly different issue where range requests were breaking audio in Safari due to the SW failing to apply the
Content-Rangeheader. I applied the range header patch using patch-package and it fixed the issue.Added patch thingy while waiting for angular/angular#25865
Added patch thingy while waiting for angular/angular#25865
fergalmoran commentedon Jun 9, 2019
Turns out this is actually fixed now by appending ngsw-ignore to your querystring or as a header.
https://github.com/angular/angular/blob/master/aio/content/guide/service-worker-devops.md
tehXor commentedon Jun 10, 2019
That is just another workaround to ignore videos (though it is one of the best workarounds in that regard so far).
But you still cannot include videos in your service worker's caching strategy when you need seeking. So no, I wouldn't say this is fixed.
gkalpak commentedon Jun 10, 2019
As mentioned in #25865 (comment), if someone wants to take a stub at incorporating range handling into the SW, I'd be happy to help/review. How do other implementations (e.g. workbox) handle this?
24 remaining items
muuvmuuv commentedon Mar 10, 2023
Hm, what is needed here to get this to work properly?
In our case, we load many PDFs, each must be cached for offline usage, which works, but range requests do not. Weirdly, it only does not work for giant PDFs, above 6 MB.
StrixOSG commentedon Dec 14, 2023
Same issue here with range requests and the service worker. We're using @philnash's patch, but we shouldn't have to. Any updates on this?
nabby27 commentedon May 1, 2024
I would like this issue to be resolved, which is why I have posted a $60 reward. I would like to contribute but I don't have time to solve it and that's why I thought that a monetary contribution could help attract people who want to help (especially seeing that it is an issue that has been open for quite some time)
turijanAldo commentedon Nov 25, 2024
If the video file is still being served by the Service Worker, you can force the video to load directly from the network by appending a unique parameter to the video URL, such as a timestamp or identifier:
const videoElement = document.getElementById('myVideo');
const videoSource = document.getElementById('myVideoSrc');
videoSource.src =
video.mp4?nocache=${Date.now()}; // Prevent cachingvideoElement.load();
videoElement.currentTime = 100;
videoElement.play();
If you need to serve large videos, consider configuring a web server with range request support, such as Nginx or Apache. This ensures that the browser can handle seeking (currentTime) properly.
Beanminchild commentedon Feb 19, 2025
#60007
Hey i took a stab at it ... is this looking like what you all wanted to do?
I just made a quick draft to confirm if this is the solution desired since there was a lot of discussion over this. Open to any and all feedback or requested changes.
Beanminchild commentedon Feb 20, 2025
can anyone take a look and tell me if im missing anything ? i think this is all we need to do.
Beanminchild commentedon Jun 22, 2025
@nabby27 hey i fixed this issue can i get the opire bounty?
fix(service-worker): bypass cache for range requests to fix video/aud…
arturovt commentedon Sep 29, 2026
@JeanMeche this can be closed. Range request support is a new feature for the service worker, and the package is in maintenance mode where only security fixes are accepted. Open since 2018 at P4, so it is not going to happen.
JeanMeche commentedon Sep 29, 2026
Per
angular/packages/service-worker/README.md
Lines 1 to 6 in 4e17af7
We'll be closing this issue.
angular-automatic-lock-bot commentedon Oct 30, 2026
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.