-1

I have an Angular based PWA app (based on the service-worker) which is working fine offline in all modern browsers, To support IE I have added "manifest.appcache" which enable IE works offline by HTML5 App Cache.

Is there Any way which can disable Appcache in all other browsers except IE ? Currently in modern browsers Appcache is also working along with service worker

i have tried below

<html lang="en" manifest="manifest.appcache" *ngIf="isIE">
<html lang="en" *ngIf="!isIE">

In component

const isIE = /msie\s|trident/i.test(window.navigator.userAgent);

But Seems HTML render before the component set value of the isIE

Shailendra Sharma
  • 6,976
  • 2
  • 28
  • 48

2 Answers2

1

I haven't tested in on IE, but from this SO answer it looks like it will not work if the manifest is set client side.

In this case, then you can set this attribute server side using angular universal.

import {Request} from 'express';
import {REQUEST} from '@nguniversal/express-engine/tokens';

public constructor(@Inject(PLATFORM_ID) private platformId, 
            @Optional() @Inject(REQUEST) protected request: Request,
            @Inject(DOCUMENT) private  doc: Document, private renderer: Renderer2)
    {

        if(!isPlatformBrowser(platformId))
        {
          const isIE = /msie\s|trident/i.test(request.headers['user-agent']);
          if(isIE)
          {
            this.renderer.setAttribute(this.doc.documentElement,"manifest","manifest.appcache");
          }
        }

If you are not using angular universal and cannot/do not want to use it, you need to find some other way to modify the index.html file server side before returning it.

David
  • 33,444
  • 11
  • 80
  • 118
-1

I tried to search but did not get any solution for this issue.

I did not get any way to disable the AppCache for other browsers except IE browser.

Even if you manage to remove the manifest attribute then also browser will use the Appcache.

The only way to disable it to remove the manifest file from the server which will also disable the Appcache for the IE browser. See here.

I suggest you show a message on the IE window that your app does not support offline mode for the IE browser and recommend your clients to use latest Microsoft browsers.

Deepak-MSFT
  • 10,379
  • 1
  • 12
  • 19
  • This is not the solution – Shailendra Sharma Apr 16 '20 at 09:41
  • There are no official ways available to do this thing. adding the manifest dynamically may need to refresh the page to take its effect which can be unwanted behavior for users and it can also cause performance issues. I will try to search for other possible ways and I will inform you if I get any helpful information. Thanks for your understanding. – Deepak-MSFT Apr 17 '20 at 05:27