3

I am trying to work with CACHE MANIFEST since there is still no full support for Service Workers across browsers. I was using (SWPrecacheWebpackPlugin) and it worked well but on IOS service workers are not working. So I went back to use App Cache and used offline-plugin webpack plugin. Problem with this is that with SWPrecacheWebpackPlugin and can add external regex for dynamic images and other requests but I don't think this is possible with AppCache Manifest. Please suggest a way. I want to add a additional external pattern for image and html page, for example, a page with pattern /details-101, /detail-102 and all images that these pages have pattern like img.cdn.com/something/some.jpeg.

Sample App Manifest file

CACHE MANIFEST
#ver:3/1/2017, 0:00:00 PM
#plugin:4.6.1

CACHE:
/img/icons.ad7bcdc.png
/img/logo.a04e995.png
/img/logo.12c22c8.png
/vendor.bundle.js
/style.css
/details-*
https://fonts.googleapis.com/css?family=Montserrat:500,700
http://fonts.googleapis.com/icon?family=Material+Icons

NETWORK:
*
rohitpal
  • 455
  • 1
  • 6
  • 21
  • You're using Webpack, right? Couldn't you just, using Webpack, generate your appcache file with all the images you use already in the cache? – bren Mar 03 '17 at 14:45
  • @MayorMonty There are many images on page, images are being shown as gallery from remote API, so resource content is dynamic – rohitpal Mar 03 '17 at 14:50
  • Is there a format or pattern to them? – bren Mar 03 '17 at 14:52
  • Yes there is pattern would be something like https://IMG.cdn.com/**/*. JPEG Also I have me tioned jtml page also have to be cache which is also based on a pattern. With service workers I simply used swprecache with specific networking strategies. – rohitpal Mar 03 '17 at 14:54
  • Here's an idea: what if, when you're online, you add a listener to all the images, so when they `onload`, you can grab the Blob and store it in IndexedDB. Then, later when you're offline, you can restore the images from IndexedDB, and then make the request, if it returns, update the image, if it fails, don't change it. I'll make a prototype, and show you what I found – bren Mar 03 '17 at 15:04
  • Are your images CORS-compliant? – bren Mar 03 '17 at 15:47
  • Yes. they are public. – rohitpal Mar 03 '17 at 16:18
  • This is not possible, every file (except the one including the cache manifest) which should be cached has to be put on a seperate line. – maraca Mar 09 '17 at 00:19

0 Answers0