How to create standalone applications with Service Worker and srcset?

I want my application (static website) to run autonomously using Service Worker. I see no way to do this without caching all the images from the attribute srcset. I can see how the clientโ€™s hints will solve the problem, but, besides, is there a solution that will work without involving a server doing anything other than using the requested files?

I see if it is possible how Service Worker can calculate the image for the query, taking into account the information in the tag imgand the naming conventions for the images ...

Has anyone solved this problem or even thought about it?

+4
source share
1 answer

For full functionality srcsetyou will have to cache all permissions.

Although the density of the screen may seem to be a fixed property of the device, it is actually dynamic, for example. The smartphone can display / broadcast on the TV screen. On a desktop with multiple displays (such as a Retina MacBook with an external display), the screen resolution may change when you move the browser window. All these changes can happen offline after you have done the caching, so you cannot know exactly which permissions will be selected.

- 2x . DPI , , .

- srcset URL- , , , . BTW: onerror="โ€ฆ" , , - , img.complete && !img.naturalWidth, .

+1

All Articles