Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

window.caches is undefined in Android Chrome, but is available at Desktop Chrome

I am a bit confused with regards to availability of Caches API on mobile devices.

https://developer.mozilla.org/en-US/docs/Web/API/CacheStorage

Documentation states this API is available on both service worker scope and window scope.

I can clearly access it on desktop's Chrome without issues.

Now whenever I do feature detection on Android's Chrome I get undefined as if feature is not available.

I tried to detect this way:

if ('caches' in window)...
if ('caches' in self)...

calling from console log via connected device etc

What do I miss?

PS: I understand Safari has very basic implementation so I expected this to go wrong with Safari, but here I am testing it with Chrome on Android;/

like image 447
Sergey Rudenko Avatar asked Nov 01 '18 02:11

Sergey Rudenko


People also ask

How do I view Chrome cache on Android?

Launch Chrome browser and tap on the three dots in the top right corner and click on the Settings from the menu. Now, navigate to the Site Settings and select Data Stored. On the new page, you will see all the sites and the cache files stored by them.

What is cache storage in Chrome?

The Chrome cache pre-stores files like images and web pages that sit on your hard drive for faster access if you were to visit the same pages again or pages that have the same components. Having this data on the hard drive can be a privacy issue for some people.


1 Answers

It seems window.caches (CacheStorage) is only available on chrome mobile when the page is served through SSL.

I'm testing with my Progressive Web App (PWA), containing a Service-Worker for caching and a manifest file.

When serving the PWA via HTTP over the LAN window.caches is not available. When served via a domain-name with SSL enabled, window.caches is available and behaves like on the Desktop-Version of chrome. It doesn't make a difference, whether you run it in a browser tab or standalone (when added to home-screen).

Edit: In fact, the same behavior also applies to chrome on desktop. Caching on my app was working only, because i tested with 'localhost' or 127.0.0.1. On any other domain / ip-address, caching gets denied when not using ssl.

like image 162
uhon Avatar answered Oct 02 '22 04:10

uhon